what is Critical section is all about?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers what is Critical section is all about?
# 1  
Old 04-05-2006
what is Critical section is all about?

what is a critical section?why multipleprocesses or multiplethreads cant be given a chance to access the critical section?

please explain me with an example.


thanks
# 2  
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.
# 3  
Old 04-07-2006
How can you Interprete with Task

Thanks pal.

but how can you interprete the same for a Task.
that is multiple tasks try to access a shared resource should not be allowed.

what is this?
# 4  
Old 04-07-2006
Well you said it all. It's the same deal. An example is you and I are on the same system and both want to change our passwords at exactly the same time. One of us will succeed..the other will see a message about the password file being locked.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

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. 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

7. 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

8. 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

9. Solaris

Monitroing Critical Logs

Hi, What are the critical logs need constant monitoring ? thanks (2 Replies)
Discussion started by: sol8admin
2 Replies
Login or Register to Ask a Question