Understanding semaphores

I read about semaphores in "Operating System Concepts" (for those of you who know this), and I thought I understood the semaphores completely until I read this passage:

A critical aspect of semaphores is that they execute atomically. We must ensure that two processes cannot wait and operate on signals on the same semaphore at the same time.

And:

If the hardware does not contain any special atomic instructions, we can use any of the software solutions for the critical section of the problem, when the critical sections consist of a wait and a signal of the procedure.

This passage refers to the face Signaland the Waitoperation must be atomic. I thought the whole purpose of the semaphore was to allow only one process in the critical section at any given time - if I need to use another algorithm (for example, a bakery algorithm), why do I also need a semaphore?

I understand that my question can be confusing. If this is so, it is only because the subject is still vague for me, so even asking a question is a little difficult.

I would like to read any clarifications ...

+3
source share
5 answers

, . , , . , . .

, , , , . , ( /).

. . http://en.wikipedia.org/wiki/Semaphore_ ()

+4

- , . , , . ? , "/". "" "" , .

, , "", "" , ? , "" "" . , , "".

+3

, . , , , Signal/Wait. , .

, , Signal Wait. ( , , .)

, , , .

+1

. , . , , , .

. , .

:

0

I asked the same question to a professor in the class, and his answer was โ€œThink of semaphores like a hammer, and as soon as you have a hammer, you can do a lot of things with it, whereas with atomic support for hardware or a software solution for mutual exclusion, such as Peterson or Bakery, limited. "

-3
source