
User’s Manual U14833EJ2V0UM
46
CHAPTER 5 SYNCHRONOUS COMMUNICATION MANAGEMENT
This chapter describes the synchronous communication management performed by the RX4000.
5.1
Overview
In an environment where multiple tasks are executed concurrently (multitasking), the result produced by a certain
task may determine the next task to be executed or affect the processing performed by the subsequent task. In other
words, it may happen that some task execution conditions vary with the processing performed by another task, or that
the processing performed by some tasks is related.
Liaison functions are therefore required between tasks so that task execution will be suspended to await the result
output by another task. These functions are known as synchronization and communication functions, and in the
RX4000 the synchronization and communication functions provided include semaphores, event flags, data queues,
mailboxes, and mutexes. These functions are described in the following sections.
5.2
Semaphores
The elements required to execute tasks are known as resources, which include all the hardware components, such
as the processor, memory, and I/O devices, and software components, such as the files and programs.
Because it is often impossible for multiple tasks to simultaneously use the same resource, a multitasking
environment requires a function to prevent possible resource contention. As a means of realizing the exclusive control
of resources that would prevent this kind of contention, the RX4000 provides non-negative counter-type semaphores.
Semaphores contain counters for controlling the number of resources, and by treating semaphores as abstract
resources, it becomes possible to perform exclusive control between tasks.
5.2.1
Creating semaphores
Semaphores can be created either by issuing the service call (a)cre_sem, or by specifying the static
APICRE_SEM, which performs equivalent processing to (a)cre_sem when the system is initialized.
If (a)cre_sem is issued, the attribute, initial counter value, and maximum counter value (etc.) are stored in the block
corresponding to the ID number that specifies the semaphore control block area secured as an array, and that control
block is then initialized.
The semaphore ID number consists of a unique number of a value 1 or higher. The maximum value that can be
specified is the one defined in the system information table, up to a maximum of 0x7fff numbers. Any value of 0 or
higher can be specified for a semaphore’s initial counter value, and any value of 1 or higher for the maximum counter
value, but the former cannot exceed the latter. The maximum specifiable value is 0x7ffffff.