
Application example for
semaphores
Tasks:
Four CPUs are plugged into an S5-155U. They output status messages to a
status signalling device via a common memory area of the O peripherals
(OW 6). A CPU must output each status message for 10 seconds. Only after a
10 second output can a new message be output from the same CPU or a
different CPU overwrite the first message. The use of peripheral word OW 6
(extended I/O area, no process image) is controlled by a semaphore. Only the
CPU that was able to reserve this area for itself by disabling the assigned
semaphore can write this message to OW 6. The semaphore remains disabled for
10 seconds at a time (TIMER T 10). The CPU re-enables the semaphore only
after this timer has elapsed. After the semaphore has been re-enabled, the
other CPUs can access the reserved area. The new message can then be written
to OW 6.
Implementation:
The following program can run in all four CPUs, each with a different
message. The blocks shown below are loaded.
5 flags are used as follows:
F 10.0 = 1:
a message was requested or is being processed
F 10.1 = 1:
the semaphore was disabled successfully
F 10.2 = 1:
the timer was started
F 10.3 = 1:
the message was transmitted
F 10.4 = 1:
the semaphore was re-enabled
Continued on next page
FB 1:
MAIN PROGRAM
FB 10:
REPORT
FB 100:
DISABLE SEMAPHORE
FB 110:
OUTPUT REPORT
FB 101:
ENABLE SEMAPHORE
Semaphore Operations
CPU 948 Programming Guide
3 - 78
C79000-G8576-C848-04
Содержание CPU 948
Страница 10: ...Contents CPU 948 Programming Guide 1 2 C79000 G8576 C848 04 ...
Страница 32: ...Contents CPU 948 Programming Guide 2 2 C79000 G8576 C848 04 ...
Страница 72: ...Data Blocks CPU 948 Programming Guide 2 42 C79000 G8576 C848 04 ...
Страница 74: ...Contents CPU 948 Programming Guide 3 2 C79000 G8576 C848 04 ...
Страница 154: ...Contents CPU 948 Programming Guide 4 2 C79000 G8576 C848 04 ...
Страница 200: ...Contents CPU 948 Programming Guide 5 2 C79000 G8576 C848 04 ...
Страница 308: ...Contents CPU 948 Programming Guide 7 2 C79000 G8576 C848 04 ...
Страница 324: ...Examples of Parameter Assignment CPU 948 Programming Guide 7 18 C79000 G8576 C848 04 ...
Страница 326: ...Contents CPU 948 Programming Guide 8 2 C79000 G8576 C848 04 ...
Страница 370: ...Addressable System Data Area CPU 948 Programming Guide 8 46 C79000 G8576 C848 04 ...
Страница 372: ...Contents CPU 948 Programming Guide 9 2 C79000 G8576 C848 04 ...
Страница 404: ...Operations with the Base Address Register BR Register CPU 948 Programming Guide 9 34 C79000 G8576 C848 04 ...
Страница 486: ...Contents CPU 948 Programming Guide 11 2 C79000 G8576 C848 04 ...
Страница 522: ...PG Functions via the S5 Bus CPU 948 Programming Guide 11 38 C79000 G8576 C848 04 ...
Страница 524: ...Contents CPU 948 Programming Guide 12 2 C79000 G8576 C848 04 ...
Страница 538: ...Contents CPU 948 Programming Guide 13 2 C79000 G8576 C848 04 ...
Страница 546: ...List of Key Words CPU 948 Programming Guide Index 6 C79000 G8576 C848 04 ...