CooCox 1.1.4 on mbed with simple blinky example

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

sem.c File Reference

sem.c File Reference

Semaphore management implementation code of CooCox CoOS kernel. More...

Go to the source code of this file.

Functions

OS_EventID CoCreateSem (U16 initCnt, U16 maxCnt, U8 sortType)
 Create a semaphore.
StatusType CoDelSem (OS_EventID id, U8 opt)
 Delete a semaphore.
StatusType CoAcceptSem (OS_EventID id)
 Accept a semaphore without waitting.
StatusType CoPendSem (OS_EventID id, U32 timeout)
 wait for a semaphore
StatusType CoPostSem (OS_EventID id)
 Post a semaphore.
StatusType isr_PostSem (OS_EventID id)
 Post a semaphore in ISR.

Detailed Description

Semaphore management implementation code of CooCox CoOS kernel.

Version:
V1.1.4
Date:
2011.04.20

INTERNAL FILE,DON'T PUBLIC.

© COPYRIGHT 2009 CooCox

Definition in file sem.c.


Function Documentation

StatusType CoAcceptSem ( OS_EventID  id )

Accept a semaphore without waitting.

Parameters:
[in]idEvent ID
[out]None
Return values:
E_INVALID_IDInvalid event ID.
E_SEM_EMPTYNo semaphore exist.
E_OKGet semaphore successful.
Description

This function is called accept a semaphore without waitting.

Definition at line 119 of file sem.c.

OS_EventID CoCreateSem ( U16  initCnt,
U16  maxCnt,
U8  sortType 
)

Create a semaphore.

Parameters:
[in]initCntSemaphore valid counter.
[in]maxCntSemaphore max initialize counter.
[in]sortTypeSemaphore sort type.
[out]None
Return values:
E_CREATE_FAILCreate semaphore fail.
othersCreate semaphore successful.
Description

This function is called to create a semaphore.

Definition at line 36 of file sem.c.

StatusType CoDelSem ( OS_EventID  id,
U8  opt 
)

Delete a semaphore.

Parameters:
[in]idEvent ID which to be deleted.
[in]optDelete option.

  • == OPT_DEL_ANYWAY Delete semaphore always
  • == OPT_DEL_NO_PEND Delete semaphore only when no task pending on.
[out]None
Return values:
E_INVALID_IDInvalid event ID.
E_INVALID_PARAMETERInvalid parameter.
E_TASK_WAITTINGTasks waitting for the event,delete fail.
E_OKEvent deleted successful.
Description

This function is called to delete a semaphore.

Note:

Definition at line 82 of file sem.c.

StatusType CoPendSem ( OS_EventID  id,
U32  timeout 
)

wait for a semaphore

Parameters:
[in]idEvent ID.
[in]timeoutThe longest time for writting semaphore. 0 0x1~0xff
[out]None
Return values:
E_CALLError call in ISR.
E_INVALID_IDInvalid event ID.
E_TIMEOUTSemaphore was not received within the specified 'timeout' time.
E_OKThe call was successful and your task owns the resource,or the event you are waiting for occurred.
Description

This function is called to waits for a semaphore.

Note:
IF this function is called in ISR,nothing to do and return immediately.

Definition at line 171 of file sem.c.

StatusType CoPostSem ( OS_EventID  id )

Post a semaphore.

Parameters:
[in]idid of event control block associated with the desired semaphore.
[out]None
Return values:
E_INVALID_IDParameter id passed was invalid event ID.
E_SEM_FULLSemaphore full.
E_OKSemaphore had post successful.
Description

This function is called to post a semaphore to corresponding event.

Note:

Definition at line 252 of file sem.c.

StatusType isr_PostSem ( OS_EventID  id )

Post a semaphore in ISR.

Parameters:
[in]ididentifier of event control block associated with the desired semaphore.
[out]None
Return values:
E_INVALID_IDParameter id passed was invalid event ID.
E_NO_TASK_WAITTINGThere are one more tasks waitting for the event.
E_OKSemaphore had signaled successful.
Description

This function is called in ISR to post a semaphore to corresponding event.

Note:

Definition at line 301 of file sem.c.