![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| 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 !! |
|
|
||||
| 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 |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
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 |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
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
|
|||
|
|||
|
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
|
||||
|
||||
|
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.
|
||||
| Google The UNIX and Linux Forums |