1
0
Files
irix-657m-src/eoe/man/man3p/taskblock.3p
2022-09-29 17:59:04 +03:00

104 lines
2.6 KiB
Plaintext

'\"macro stdmacro
.TH TASKBLOCK 3P LOCAL
.SH NAME
taskblock, taskunblock, tasksetblockcnt \- routines to block/unblock tasks
.Op c p a
.SH C SYNOPSIS
.B #include <sys/types.h>
.br
.B #include <task.h>
.P
.br
.B int taskblock (tid_t tid);
.P
.br
.B int taskunblock (tid_t tid);
.P
.br
.B int tasksetblockcnt (tid_t tid, int count);
.Op
.Op f
.SH FORTRAN SYNOPSIS
.B integer*4 function taskblock (tid)
.br
.B integer*4 tid
.P
.br
.B integer*4 function taskunblock (tid)
.br
.B integer*4 tid
.P
.br
.B integer*4 function tasksetblockcnt (tid, count)
.br
.B integer*4 tid
.br
.B integer*4 count
.Op
.SH DESCRIPTION
These routines provide a complete set of blocking/unblocking capabilities
for tasks.
Blocking is implemented via a counting semaphore in the system.
Each call to
.I taskblock
decrements the count and, if it goes negative, the task is
suspended.
When
.I taskunblock
is called, the count is incremented, and if it goes positive (or zero), the
task is re-started.
This provides both a simple, race free synchronization ability between
two tasks, as well as a much more powerful capability to synchronize
multiple tasks.
.PP
In order to guarantee a known starting place the
.I tasksetblockcnt
function may be called which will force the semaphore count to the value
given by
.I count.
New tasks have their semaphore zeroed.
Normally,
.I count
should be set to 0.
If the resulting block count is greater than or equal to zero and the
task is currently blocked, it will be unblocked.
If the resulting block count is less than zero, the task will be blocked.
Using this, a simple rendezvous mechanism can be set up.
If one task wanted to wait for
.I n
other tasks to complete, it could set its block count to
.I -n.
This would immediately force the task to block.
Then as each task finishes it unblocks the waiting task.
When the
.I n'th
task finishes the waiting task will be woken.
.PP
A task may block another task provided that standard
UNIX permissions are satisfied.
.PP
These routines
will fail and no operation will be performed if one or more of the
following are true:
.TP
.SM
\%[EINVAL]
The
.I tid
specified is not a valid task id.
.TP
.SM
\%[EPERM]
The caller is not operating on itself, its effective user ID is not super-user,
and its real or effective user ID does not match the real or effective
user ID of the to be acted on task.
.SH "SEE ALSO"
blockproc(2), taskdestroy(3P), taskctl(3P), taskcreate(3P).
.SH DIAGNOSTICS
Upon successful completion, 0 is returned.
Otherwise, a value of \-1 is
returned to the calling task, and
.I errno\^
is set to indicate the error.
'\".so /pubs/tools/origin.sgi