Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

critical sections

0 views
Skip to first unread message

Steven J. Lee

unread,
Jan 19, 1997, 3:00:00 AM1/19/97
to

Hello,

Does anyone know how to obtain the functionality of critical sections
(as they are implemented in OS/2) in win32? With OS/2, while a thread
is in a critical section, no other thread of that thread's process will
be scheduled to run. So it effectively disables context switching for a
given process. Windows critical sections are not implemented this way.

Does anyone know how to do this in Windows?

thanks!

--
Steve Lee, Software Engineer voice: (515) 296-0768
NewMonics Inc. fax: (515) 294-9910
2501 N. Loop Dr., Suite 614-A internet: sj...@newmonics.com
Ames, IA 50010 http://www.newmonics.com

Supporting PERC(TM): Portable Executive for Reliable Control

Alistair mackay

unread,
Feb 21, 1997, 3:00:00 AM2/21/97
to

In article: <32E2D4...@newmonics.com> "Steven J. Lee"
<sj...@newmonics.com> writes:
>
> Hello,
>
> Does anyone know how to obtain the functionality of critical sections
> (as they are implemented in OS/2) in win32? With OS/2, while a thread
> is in a critical section, no other thread of that thread's process will
> be scheduled to run. So it effectively disables context switching for a
> given process. Windows critical sections are not implemented this way.
>
> Does anyone know how to do this in Windows?
>
> thanks!

From my own experience, using critical sections in Windows works thus:

When a thread calls EnterCriticalSection() other threads are blocked
at their call to EnterCriticalSection() on the same CRITICAL_SECTION object
until such time as the referenced CRITICAL_SECTION object is available (ie
when the owning thread calls LeaveCriticalSection()).
I generally use this to control multiple thread's access to a shared
resource, such as a global variable or a common file.

I can't see any other reason for suspending the other threads, but if this
is what you need to do, I think you'll have to call SuspendThread() on all
the other threads.

Hope this helps.
--
------------------------------------------------------------------------
| A. Mackay EMail ed...@tag.co.uk |
| http://www.tag.co.uk/tag/ |
| Technology Applications Group |
| |
| Comments are my own and do not reflect the policies of the company I |
| work for. No responsiblitly accepted for incorrect advice given. |
------------------------------------------------------------------------

0 new messages