please advice. thanks...
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.
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>
>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
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.
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?
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
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.
Its funny over there!
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
>>
>> 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!