Find the answer to your Linux question:
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 ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just 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

  2. #2
    Linux User cyberinstru's Avatar
    Join Date
    Jan 2007
    Location
    India
    Posts
    362
    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:

    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);
    }
    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.

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

  3. #3
    Just Joined!
    Join Date
    Jan 2007
    Posts
    3

    Question 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

  4. $spacer_open
    $spacer_close
  5. #4
    Linux User cyberinstru's Avatar
    Join Date
    Jan 2007
    Location
    India
    Posts
    362
    ---------------------------------
    Registered Linux User #440311
    HI2ARUN _AT_ GMAIL _DOT_ COM
    ---------------------------------

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •