06.08.2013 Views

pSOSystem System Calls - Read

pSOSystem System Calls - Read

pSOSystem System Calls - Read

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.

sm_p pSOS+ <strong>System</strong> <strong>Calls</strong><br />

sm_p Acquires a semaphore token.<br />

#include <br />

unsigned long sm_p(<br />

unsigned long smid, /* semaphore identifier */<br />

unsigned long flags, /* attributes */<br />

unsigned long timeout /* timeout */<br />

)<br />

Description<br />

Arguments<br />

Return Value<br />

This system call enables a task or an ISR to acquire a semaphore token. A calling<br />

task can specify whether or not it wants to wait for the token. If the semaphore<br />

token count is positive, then this call returns the semaphore token immediately. If<br />

the semaphore token count is zero and the calling task specified SM_NOWAIT, then<br />

sm_p() returns with an error code. If SM_WAIT is elected, the task will be blocked<br />

until a semaphore token is released, or if the timeout argument is specified, until<br />

timeout occurs, whichever occurs first.<br />

smid Specifies the semaphore ID of the semaphore token.<br />

flags Specifies whether sm_p() will block waiting for a token. flags<br />

should have one of the following values (defined in ):<br />

SM_WAIT Block until semaphore is available.<br />

SM_NOWAIT Return with error code if semaphore is<br />

unavailable.<br />

timeout Specifies the timeout interval, in units of clock ticks. If timeout is<br />

zero and flags is set to SM_WAIT, then sm_p() will wait forever.<br />

timeout will be ignored if flags is set to SM_NOWAIT.<br />

This system call returns 0 on success, or an error code on failure.<br />

1-128 <strong>pSO<strong>System</strong></strong> <strong>System</strong> <strong>Calls</strong>

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

Saved successfully!

Ooh no, something went wrong!