Critical section in C#.net

Posted by Naraayanan under C# on 12/14/2011 | Points: 10 | Views : 4319 | Status : [Member] | Replies : 2
What is mean b Critical section and How to handle critical section in C#?

Regards,
Lakshmi Naraayanan.S
http://dotnettechrocks.blogspot.in/
http://abaprocker.blogspot.com/



Responses

Posted by: Oswaldlily on: 12/14/2011 [Member] Starter | Points: 25

Up
0
Down
The Critical Section Problem
I assume you have read the tutorial on cooperating processes, and Interprocess Communication (IPC) facilities provided by the Operating System for process cooperation. The most synchronization problem confronting cooperating processes, is controling access to shared resource. Suppose two processes share access to a file, or shared memory segment (or when we discuss threads in a couple of weeks, we'll see threads share the same memory, so they must synchronize their actions), and at least one of these processes can modify the data in this shared area of memory. That part of the code of each program, where one process is reading from or writing to a shared memory area, is a critical section of code, because we must ensure that only one process execute a critical section of code at a time
Suppose a Consumer must have the data in the BUFFER, but BUFFER is empty. The only way to determine whether data has been added to the buffer is to continually enter the Critical Section and check COUNTER. This creates what is called a spinlock, where the process enters a useless cycle waiting for a resource. If the resource will be available quickly, this is not a problem; but if the resource may take some time, this spinlock position wastes CPU time that could be more productively spent. A solution to this problem is to use a semaphore to count as well. A semaphore which is used as a counter is called a counting semaphore.


Naraayanan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Naraayanan on: 12/29/2011 [Member] Starter | Points: 25

Up
0
Down
Hi,
Thanks for your reply

Regards,
Lakshmi Naraayanan.S
http://dotnettechrocks.blogspot.in/
http://abaprocker.blogspot.com/

Naraayanan, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response