Talk:Critical section
From Wikipedia, the free encyclopedia
A critical section is a piece of code. but it isn't critical because executing itself, it is critical because the code causes a effect, at example change data. Two different pieces of code are critical together, the CRITICAL_SECTION - mechanism in Windows doesn't protect the entering of this alone critical section code piece, it protects the entry in different critical sections which effects the same data. In this mind the CRITICAL_SECTION-mechanism in Windows is a simple semaphore and the problem is a mutex problem.
I would say, a critical section is a piece of code, it's right. But the reason for a critical section may be several:
- mutex, exclusively acces to data
- time-critical actions like hardware access (microsecond-impuls generated by software). A interruption of this critical section can extend the time of a hardware pulse in a unneeded manner.
- prevent a thread switch (from a thread in a lower priority at example) to finish a mutex access in a short time, if the mutex access may block a high priority thread. The low priority thread mustn't be interrupted by a middle priority thread in this critical section.
That are three several examples. I would think, the explanation of critical section may be corrected in this mind. --HartmutS 18:43, 26 April 2006 (UTC)
Another important aspect is partial mutual exclusion. For example, code protected by the read side of a reader-writer lock excludes writers, but not other readers. Seems like some modification is in order to account for this -- in its current form, the article only allows for exclusive locks. PaulMcKenney 15:00, 26 May 2006 (UTC)
Gurudutt 10:16, 10 September 2007 (UTC) It should be possible to use pthread_spin_lock() family of functions to get Critical Section in User Mode in Pthreads Library. The current example shows the use of Mutex Object (kernel level)?? Being a newcomer to threading and esp. Pthreads this is just my 2 cents worth.

