sends one, or that a message exist on the queue before a process receive one.

A semaphore

is a synchronization mechanism similar

to a mutex or a mac

interface

(MI) lock. It can be used to control

access to shared r

to notify

other processes of the availability

of resources.

Processes can communicate directly with one another by sharing parts memory space and then reading and writing the datashared stored in the

memory . Synchronization of shared memory is the responsibility of the program. Semaphores can be used to synchronize shared memory use acr processes. Mutexes or condition variables can be used to synchronize memory use across threads.

Although each IPC service provides a specific type of interprocess the three services share many similarities. Each service defines a

through

which

its communications take place. For

message

queues, that

anism is a message queue; for semaphores, it

is a semaphore set; a

memory,

it is

a shared memory segment. These

mechanisms

are identifie

unique positive integer, called, respectively, a messagemsqid),queuea identi

semaphore identifiersemid), (and

a shared memory identifiershmid).

(

 

Associated with

each

identifier

is a

data

structure

that contains

the IPC

mechanism, as

well

as

ownership

and

permissions

information. This

ture is similar to a file permissions

structure,

and

is initialized

b

creates

the IPC

mechanism. It

is

then

checked

by

all

subsequent

IP

to determine if the requesting process has the required permissions operation.

To get

an

identifier,

a process must

either

create a

new IPC

mech

an existing mechanism. This is done throughmsgget()

,thesemget() ,

and

 

 

shmget()

functions. Each

get operation takeskeyasparameterinput a and

 

returns

an

identifier.

Each

get

operationflag alsoparametertakes. Thisaflag

 

 

parameter

contains the

IPC permissions for the mechanism as well as b

determine whether or not a

new

mechanism

is

created.

 

 

When a

message queue,

semaphore

set,

or

shared

memory

segment

is c

the process that creates it determines how it can be accessed. Su

operations

do a

permission test for the calling process before allow

to perform

the

requested operation.

Signal APIs

An X/Open**

specification

1

as “a mechanism by which a process

definessignal

may be notified of, or

affected by, an event occurring in the sy

signal is

also used to

refer to the event itself.

A signal is said to be whgeneratedthe event that causes the signal first Examples of such events include the following:

ŸSystem-detected errors

ŸTimer expiration

1X/Open CAE Specification System Interface Definitions Issue 4, Number 2, Glossary, page 27. X/Open Company Kingdom, 1994.

Chapter 8. Use of OS/400 8APIs-23

Page 199
Image 199
IBM Version 4 Signal APIs, Semaphore, Are identifie, Shmget, An X/Open Specification As a mechanism by which a process