30.12.2013 Views

T-Kernel Specification (1.B0.02)

T-Kernel Specification (1.B0.02)

T-Kernel Specification (1.B0.02)

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

4.4. SYNCHRONIZATION AND COMMUNICATION FUNCTIONS 79<br />

tk cre sem<br />

Create Semaphore<br />

[C Language Interface]<br />

ID semid = tk_cre_sem ( T_CSEM *pk_csem ) ;<br />

[Parameters]<br />

T CSEM* pk csem Information about the semaphore to be created<br />

pk csem detail:<br />

VP exinf Extended information<br />

ATR sematr Semaphore attributes<br />

INT isemcnt Initial semaphore count<br />

INT maxsem Maximum semaphore count<br />

(Other implementation-dependent parameters may be added beyond this point.)<br />

[Return Parameters]<br />

ID semid Semaphore ID<br />

or Error Code<br />

[Error Codes]<br />

E OK<br />

E NOMEM<br />

E LIMIT<br />

E RSATR<br />

E PAR<br />

Normal completion<br />

Insufficient memory (memory for control block cannot be allocated)<br />

Semaphore count exceeds the system limit<br />

Reserved attribute (sematr is invalid or cannot be used)<br />

Parameter error (pk csem is invalid; isemcnt or maxsem is negative or invalid)<br />

[Description]<br />

Creates a semaphore, assigning to it a semaphore ID.<br />

This system call allocates a control block to the created semaphore, setting the initial count to isemcnt<br />

and maximum count (upper limit) to maxsem. It must be possible to set maxsem to at least 65535.<br />

Whether values above 65536 can be set is implementation-dependent.<br />

exinf can be used freely by the user to set miscellaneous information about the created semaphore.<br />

The information set in this parameter can be referenced by tk ref sem. If a larger area is needed for<br />

indicating user information, or if the information may need to be changed after the semaphore is created,<br />

this can be done by allocating separate memory for this purpose and putting the memory packet address<br />

in exinf. The OS pays no attention to the contents of exinf.<br />

sematr indicates system attributes in its low bits and implementation-dependent information in the<br />

high bits. Designation in the system attributes part of sematr is as follows.<br />

Copyright c○ 2002, 2003 by T-Engine Forum<br />

T-<strong>Kernel</strong> <strong>1.B0.02</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!