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.6. MEMORY POOL MANAGEMENT FUNCTIONS 159<br />

tk get mpl<br />

Get Variable-size Memory Block<br />

[C Language Interface]<br />

ER ercd = tk_get_mpl ( ID mplid, INT blksz, VP *p_blk, TMO tmout ) ;<br />

[Parameters]<br />

ID mplid Variable-size memory pool ID<br />

INT blksz Memory block size (in bytes)<br />

TMO tmout Timeout<br />

[Return Parameters]<br />

ER ercd Error code<br />

VP blk Block start address<br />

[Error Codes]<br />

E OK<br />

E ID<br />

E NOEXS<br />

E PAR<br />

E DLT<br />

E RLWAI<br />

E DISWAI<br />

E TMOUT<br />

E CTX<br />

Normal completion<br />

Invalid ID number (mplid is invalid or cannot be used)<br />

Object does not exist (the variable-size memory pool designated in mplid does not exist)<br />

Parameter error (tmout ≤ (−2))<br />

The object being waited for was deleted (the memory pool was deleted while waiting)<br />

Wait state released (tk rel wai received in wait state)<br />

Wait released by wait disabled state<br />

Polling failed or timeout<br />

Context error (issued from task-independent portion or in dispatch disabled state)<br />

[Description]<br />

Gets a memory block of size blksz (bytes) from the variable-size memory pool designated in mplid.<br />

The start address of the allocated memory block is returned in blk.<br />

The allocated memory is not cleared to zero, and the memory block contents are indeterminate.<br />

If memory cannot be allocated, the task issuing this system call enters WAIT state.<br />

A maximum wait time (timeout) can be set in tmout. If the tmout time elapses before the wait release<br />

condition is met (memory space does not become available), the system call terminates, returning<br />

timeout error code E TMOUT.<br />

Only positive values can be set in tmout. The time base for tmout (time unit) is the same as that for<br />

system time (= 1 ms).<br />

When TMO POL = 0 is set in tmout, this means 0 was designated as the timeout value, and E TMOUT is<br />

returned without entering WAIT state even if memory cannot be allocated.<br />

When TMO FEVR = (−1) is set in tmout, this means infinity was designated as the timeout value, and<br />

the task continues to wait for memory allocation without timing out.<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!