The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Very Critical shikhakaul Shell Programming and Scripting 1 02-29-2008 05:16 PM
apple section kezzol OS X (Apple) 1 05-21-2007 01:17 PM
Windows section?!? PxT Post Here to Contact Site Administrators and Moderators 4 04-11-2002 06:28 AM
New Section kapilv Post Here to Contact Site Administrators and Moderators 3 10-31-2001 06:57 PM
New section ober5861 Post Here to Contact Site Administrators and Moderators 3 07-25-2001 09:16 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 04-05-2006
Registered User
 

Join Date: Mar 2006
Posts: 26
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
Reply With Quote
Forum Sponsor
  #2  
Old 04-05-2006
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,614
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.
Reply With Quote
  #3  
Old 04-07-2006
Registered User
 

Join Date: Mar 2006
Posts: 26
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?
Reply With Quote
  #4  
Old 04-07-2006
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,614
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.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 12:40 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0