Results 1 to 4 of 4
Hi ...
I wanted to know what is the re-enterent code in linux kernel.
and what is the link between re-enterent and critical section .
how we identify a critical ...
- 02-26-2007 #1Just Joined!
- Join Date
- Jan 2007
- Posts
- 3
re-enterent code
Hi ...
I wanted to know what is the re-enterent code in linux kernel.
and what is the link between re-enterent and critical section .
how we identify a critical section in the code with out locks.
if possible give me some examples also.
regards
shankar
- 02-26-2007 #2
Critical section in kernel: This is nothing but the code that works on a shared resource.
Re-Entrancy: Accessing a shared code (may be a common routine) by more than one task.
Example:
Let's consider, the example code is used by more than one tasks and this code accesses the shared area (here XYZ). As this code is used by more than one tasks, this is called the re-entrant code. When this code is in code segment (during execution), this part becomes the critical section.Code:global XYZ; // Shared resource RETURN CriticalSection (arguments, ...) { INT32 abc; ... ... lock (XYZ); // Acquire lock to access XYZ XYZ = x*y+233; // Manipulate XYZ ... unlock (XYZ); //Release lock .... return (RETURN); }
This is the relationship between critical section and re-entrancy.
Writing a safer re-entrancy code:
* Try to use local variables only
* In case global variables are used, protect them using some locking mechanisms like semaphores, etc.
hope this helps.
N.B: someone please correct me, if I am wrong---------------------------------
Registered Linux User #440311
HI2ARUN _AT_ GMAIL _DOT_ COM
---------------------------------
- 02-27-2007 #3Just Joined!
- Join Date
- Jan 2007
- Posts
- 3
critical section
hi cyberinstru,
thanks for u reply, but still i need clarification in critical section,
can i say critical section as Non-Reenterent region in reenterent region.
and u r saying that Reenternet region means nothing but accessing the shered region by many tasks , that all ?
and if have a code , how can we identify the critical section in that code?(i.e how do we know that code is used by many tasks)
warm regards
mammu
- 02-28-2007 #4---------------------------------
Registered Linux User #440311
HI2ARUN _AT_ GMAIL _DOT_ COM
---------------------------------


Reply With Quote
