Sponsored Content
Top Forums UNIX for Dummies Questions & Answers what is Critical section is all about? Post 302070545 by Perderabo on Wednesday 5th of April 2006 03:35:18 PM
Old 04-05-2006
Take the example of fork() which creates a process. fork() needs to locate an available slot in the process table. Then it puts some info in that slot for the new process it is creating. Now imagine two cpu's both executing fork() at the same time. They both need an empty slot from the process table. They both find the exact same slot. They both try to use that slot to describe the new process they each are creating. This is a disaster. Allocating an used slot from the process table is a critical section. So we need to lock the process table, and then, if we succeed in getting the lock, we allocate the slot and unlock the table. If we do not succeed in getting the lock, we wait a try again later. Now two cpu's cannot step on each other.

To help with locking stuff, there is usually a machine language instruction that, in one step, tests a byte in memory for zero and, if it was zero, set it to 1. Even if two cpus execute the instruction at the same time, it will completely work for one them and completely fail for the other.
 

9 More Discussions You Might Find Interesting

1. Solaris

Monitroing Critical Logs

Hi, What are the critical logs need constant monitoring ? thanks (2 Replies)
Discussion started by: sol8admin
2 Replies

2. Shell Programming and Scripting

Very Critical

We have a batch job which runs and checks for certain files on a server and retrieves them to our server. But from last few hours the job is not running correctly. It gives msg file now found when there are files present on the server.. Nothing has been changed.................. (1 Reply)
Discussion started by: shikhakaul
1 Replies

3. HP-UX

ServiceGuard on HP-UX 11.23 Mission Critical

Dear(s), anybody have played ServiceGuard on HP-UX version 11.23 MC ? I am planning to install Oracle and OpenView Operations for Unix 8 on a ServiceGuard clustered HP-UX environment, any suggestionsfrom where should I start ? Best Regards, Mostafa Reda (1 Reply)
Discussion started by: darousha
1 Replies

4. UNIX for Advanced & Expert Users

Shared Libraries- CRITICAL !!

Hi, I am trying to create a shared library from a .c file using gcc -c -fpic -I/usr/local/include Chksum.C -o Chksum.o gcc -shared -o libtclcksum.so Chksum.o when i try to load this shared library libtclcksum.so in tclsh % load libtclcksum.so I get the following error: couldn't load... (1 Reply)
Discussion started by: archana485
1 Replies

5. Shell Programming and Scripting

Critical problem in merging lines

Hi all, I am having a very critical problem in merging lines in my file as, let my file contents are: cat test1.txt name1....... address1....... phone1...... <blank> name2...... address2..... phone2..... <blank> and so on. Now i have to merge these lines by which my desired output... (2 Replies)
Discussion started by: shadow25
2 Replies

6. AIX

How critical is this info,from syslog?

Hello Gurus I have a linux box which is trying to connect to HOST-1 via ssh.Recently i have been submitted following entries from 'syslog' from this HOST-1. As you can see,there are 3 failed login attempts logged for my user 'eatcid' coming from my linux box to this HOST-1 which is AIX.The... (4 Replies)
Discussion started by: ak835
4 Replies

7. Shell Programming and Scripting

Extract section of file based on word in section

I have a list of Servers in no particular order as follows: virtualMachines="IIBSBS IIBVICDMS01 IIBVICMA01"And I am generating some output from a pre-existing script that gives me the following (this is a sample output selection). 9/17/2010 8:00:05 PM: Normal backup using VDRBACKUPS... (2 Replies)
Discussion started by: jelloir
2 Replies

8. UNIX for Advanced & Expert Users

Critical lib renamed

Hello I have moved a critical lib from its location, so all programms linked to libc dont work . I still have two shells on the machine, bash and ksh The only thing I see is copying back the lib, but of course : dd, cp , mv etc are dead . So i tryed a loop with read ... {^Jwhile read... (24 Replies)
Discussion started by: remi75
24 Replies

9. Shell Programming and Scripting

Prepend first line of section to each line until the next section header

I have searched in a variety of ways in a variety of places but have come up empty. I would like to prepend a portion of a section header to each following line until the next section header. I have been using sed for most things up until now but I'd go for a solution in just about anything--... (7 Replies)
Discussion started by: pagrus
7 Replies
plock(3C)						   Standard C Library Functions 						 plock(3C)

NAME
plock - lock or unlock into memory process, text, or data SYNOPSIS
#include <sys/lock.h> int plock(int op); DESCRIPTION
The plock() function allows the calling process to lock or unlock into memory its text segment (text lock), its data segment (data lock), or both its text and data segments (process lock). Locked segments are immune to all routine swapping. The effective user ID of the calling process must be super-user to use this call. The plock() function performs the function specified by op: PROCLOCK Lock text and data segments into memory (process lock). TXTLOCK Lock text segment into memory (text lock). DATLOCK Lock data segment into memory (data lock). UNLOCK Remove locks. RETURN VALUES
Upon successful completion, 0 is returned. Otherwise, -1 is returned and errno is set to indicate the error. ERRORS
The plock() function fails and does not perform the requested operation if: EAGAIN Not enough memory. EINVAL The op argument is equal to PROCLOCK and a process lock, a text lock, or a data lock already exists on the calling process; the op argument is equal to TXTLOCK and a text lock or a process lock already exists on the calling process; the op argument is equal to DATLOCK and a data lock or a process lock already exists on the calling process; or the op argument is equal to UNLOCK and no lock exists on the calling process. EPERM The {PRIV_PROC_LOCK_MEMORY} privilege is not asserted in the effective set of the calling process. USAGE
The mlock(3C) and mlockall(3C) functions are the preferred interfaces for process locking. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |MT-Level |MT-Safe | +-----------------------------+-----------------------------+ SEE ALSO
exec(2), exit(2), fork(2), memcntl(2), mlock(3C), mlockall(3C), attributes(5) SunOS 5.10 22 Mar 2004 plock(3C)
All times are GMT -4. The time now is 08:30 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy