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

critical section is useless in cooperative multitasking environment?

0 views
Skip to first unread message

Ken

unread,
Nov 24, 2006, 9:10:25 PM11/24/06
to
I want to understand the usage of critical sections. I understand we
use critical sections for resource access. Does it mean it should be
used in preemptive multitasking environment, not cooperative
multitasking environment?

please advice. thanks...

Joe Seigh

unread,
Nov 24, 2006, 9:28:59 PM11/24/06
to
Those are two different things. Cooperative is a forward progress
strategy to deal with lack of forward progress at the thread scheduling
level. You basically arrange it so as a thread executes it decreases
it's likelyhood of continuing to run indefinitely and increases the
chance of another thread, that may be blocked, of running. Usually
by resource usage. Producer/consumer as an example. The threads
create resources used by another thread and deplete resources created
by another thread. There's a feedback mechanism in there. So it
doesn't matter what how the thread scheduler works as long as runnable
threads are run. Java threads don't have forward progress, unless you're
using realtime java. That's why the Java docs alway mention using
cooperative multi-threading. The same is true for Posix threads although
I don't recall if the Posix docs say that also.

Preemption is a way of controlling how much execution resource a thread
uses. By itself, it doesn't guarantee forward progress. But it might
be necessary for a scheduler to implement forward progress guarantees.

Neither of these affect whether you use critical sections or not.


--
Joe Seigh

When you get lemons, you make lemonade.
When you get hardware, you make software.

CBFalconer

unread,
Nov 24, 2006, 9:49:09 PM11/24/06
to

A critical section is a section of code that requires exclusive
access to its variables.

--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net>


Sam

unread,
Nov 24, 2006, 10:20:35 PM11/24/06
to
Ken writes:

It means that you should study harder and figure out the answers to your
homework questions by yourself.

Byron A Jeff

unread,
Nov 25, 2006, 8:03:39 AM11/25/06
to
In article <1164420625.0...@m7g2000cwm.googlegroups.com>,
Ken <jav...@gmail.com> wrote:

>I want to understand the usage of critical sections. I understand we
>use critical sections for resource access.

To be more specific critical sections are used for mutually exclusive
access to a shared resource.

> Does it mean it should be
>used in preemptive multitasking environment, not cooperative
>multitasking environment?

Orthogonal question. It doesn't matter if it's preemptive or cooperative
multitasking. It only matters that if one process/thread has exclusive
access to their critical section, that no other process/thread gets
simulteaneous access to their critical section until the current resource
holder releases the resource and leaves the critical section. So if
in a cooperative situation a process/thread gives up the CPU in the middle
of a critical section, no other process/thread can get into their critical
section even though the resource holder has given up the CPU.

Hope this helps,

BAJ

Joe Seigh

unread,
Nov 25, 2006, 8:13:08 AM11/25/06
to

I was thinking that unstated assumption, that there is only a single
processor, might show up. I guess the OP doesn't go to a school that
can afford multiprocessor systems. Good to see that they're graduating
students who will be incapable of programming any modern computer.

Chris Thomasson

unread,
Nov 25, 2006, 8:46:46 AM11/25/06
to
"Joe Seigh" <jsei...@xemaps.com> wrote in message
news:L9mdnWsuYLcu3fXY...@comcast.com...

Man... STM will only make this worse. I am astonished at the apparent lack
of knowledge wrt how to handle shared mutable data. The college kids are
being taught that its far too advanced, so the professor only going to show
them how to abstract the shared memory away to a point that renders all of
its many advantages useless, e.g, STM. STM is GOD!

Ack!


Any thoughts?


Jean-David Beyer

unread,
Nov 25, 2006, 10:00:57 AM11/25/06
to
By modern computer, you mean anything like the IBM 709 or later, I presume.
Because they had multi-processors even then, in vacuum tube days. Those
machines had independent data channels that followed programs of their own,
programs that were stored in the main memory of the computer. They
synchronized with the main processor by means of interrupts that could come
in between any two instructions. Such devices these days are called
direct-memory-access (DMA) channels, but they were the latest thing back
then. This would be about 50 years ago.

Critical sections existed even then, though pretty much without hardware
support. You had to remember not to use input data before it was all there,
and not to overwrite output data until it was out. Luckily for most
programmers, the operating system took care of the details, but users were
not compelled to use the OS at all back then if they did not want to. There
was no memory management hardware, so you could not stop users from doing
anything that they wanted.

--
.~. Jean-David Beyer Registered Linux User 85642.
/V\ PGP-Key: 9A2FC99A Registered Machine 241939.
/( )\ Shrewsbury, New Jersey http://counter.li.org
^^-^^ 09:55:01 up 35 days, 12:24, 3 users, load average: 4.36, 4.15, 4.10

Joe Seigh

unread,
Nov 25, 2006, 10:09:13 AM11/25/06
to

Yes, I think you just cross threaded things here. :)
The c.o.l.m readers may not be aware that there's a STM
(software transactional memory) dicussion also going on.

Chris Thomasson

unread,
Nov 25, 2006, 10:22:20 AM11/25/06
to
Apparently, over on MSDN channel 9, they think the game industry is loaded
with threading experts who know that STM is the one true GOD!

Its funny over there!


Jean-David Beyer

unread,
Nov 25, 2006, 10:09:38 AM11/25/06
to
Yes. A question. What is STM?

Master of Sacred Theology?
Scanning tunneling microscope?
Short-term memory?
Société de transport de Montréal?
Software transactional memory?
...

I assume 3 or 5 is that to which you refer.

Critical sections and how to manage them have been known for a very long
time, _at least_ back to the THE system of Dijkstra back in the mid 1960s.

As far as "too advanced" is concerned, teachers are the only ones that know
the difference between elementary and advanced. What the teacher can teach
is elementary and what they cannot teach is advanced. The distinction is in
the ability of the teacher, not the student.

--
.~. Jean-David Beyer Registered Linux User 85642.
/V\ PGP-Key: 9A2FC99A Registered Machine 241939.
/( )\ Shrewsbury, New Jersey http://counter.li.org

^^-^^ 10:00:01 up 35 days, 12:29, 3 users, load average: 4.12, 4.14, 4.10

Chris Thomasson

unread,
Nov 25, 2006, 10:35:02 AM11/25/06
to
"Jean-David Beyer" <jeand...@verizon.net> wrote in message
news:S0Z9h.11420$w37.7912@trnddc08...

> Chris Thomasson wrote:
>> "Joe Seigh" <jsei...@xemaps.com> wrote in message
>> news:L9mdnWsuYLcu3fXY...@comcast.com...
>>> Byron A Jeff wrote:
>>>> In article <1164420625.0...@m7g2000cwm.googlegroups.com>,
>>>> Ken <jav...@gmail.com> wrote:
>>>>
[...]

>>
>> Any thoughts?
>>
>>
> Yes. A question. What is STM?
>

> Software transactional memory?
^^^^^^^^^^^^^^^^^^^^

> Critical sections and how to manage them have been known for a very long
> time, _at least_ back to the THE system of Dijkstra back in the mid 1960s.
>
> As far as "too advanced" is concerned, teachers are the only ones that
> know
> the difference between elementary and advanced. What the teacher can teach
> is elementary and what they cannot teach is advanced. The distinction is
> in
> the ability of the teacher, not the student.

Humm, Agreed.

P.S.-- sorry for cross threading this issue!


0 new messages