stason.org logo lotus


previous page: 5.3. Context switch (Programming threads)page up: Threads Programming FAQnext page: 5.5. Lightweight process (Programming threads)

5.4. Critical section (Programming threads)

 Books
 TULARC
















Description

This article is from the Threads Programming FAQ, by Bryan O'Sullivan bos@serpentine.com with numerous contributions by others.

5.4. Critical section (Programming threads)

A critical section of code is one in which data that may be accessed
by other threads are inconsistent. At a higher level, a critical
section can be viewed as a section of code in which a guarantee you
make to other threads about the state of some data may not be true.

If other threads can access these data during a critical section, your
program may not behave correctly. This may cause it to crash, lock up,
produce incorrect results, or do just about any other unpleasant thing
you care to imagine.

Other threads are generally denied access to inconsistent data during
a critical section (usually through use of locks). If some of your
critical sections are too long, however, it may result in your code
performing poorly.

 

Continue to:


Share and Enjoy

Bookmark this story so others can enjoy it:
  • digg
  • Reddit
  • del.icio.us
  • Furl
  • Wists

Tags

programming, software, coding, threads programming







TOP
previous page: 5.3. Context switch (Programming threads)page up: Threads Programming FAQnext page: 5.5. Lightweight process (Programming threads)