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 151<br />

tk get mpf<br />

Get Fixed-size Memory Block<br />

[C Language Interface]<br />

ER ercd = tk_get_mpf ( ID mpfid, VP *p_blf, TMO tmout ) ;<br />

[Parameters]<br />

ID mpfid Fixed-size memory pool ID<br />

TMO tmout Timeout designation<br />

[Return Parameters]<br />

ER ercd Error code<br />

VP blf Memory 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 (mpfid is invalid or cannot be used)<br />

Object does not exist (the fixed-size memory pool designated in mpfid 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 from the fixed-size memory pool designated in mpfid. The start address of<br />

the allocated memory block is returned in blf. The size of the allocated memory block is the value<br />

designated in the blfsz parameter when the fixed-size memory pool was created.<br />

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

If a block cannot be allocated from the designated memory pool, the task that issued tk get blf is put<br />

in the queue of tasks waiting for memory allocation from that memory pool, and waits until memory<br />

can be allocated.<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 />

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!