Download PC UNOS A Real Time Operating System
Transcript
SEMAPHORES and TIMING create_semaphore __________________________________________________________________ Function To create a new semaphore. Syntax #include “unos.h” unsigned int create_semaphore( void ); Remarks May be called at any time to create a new semaphore. The semaphore created is initialised to a value of 1 with a multiplier value of 1. NOTE: When declaring a semaphore variable, ALWAYS initialize it to 0xFFFF. In this manner, unintentioned operations on a semaphore which has not been created will be avoided, as the UNOS semaphore functions will be able to detect the illegal semaphore number. Parameters None. Return value The created semaphore's number. If unsuccessful, 0xFFFF. create_timer __________________________________________________________________ Function To create a new timer. Syntax #include “unos.h” timer_struc * create_timer( void ); Remarks After allocating the required timer structure from the UNOS heap, the timer is inserted into the inactive timer queue. Parameters None. Return value Pointer to the new timer data structure. This structure is defined in unos.h. init_semaphore __________________________________________________________________ Function To initialise a semaphore's variables. Syntax #include “unos.h” void init_semaphore( unsigned int semaphore_number, unsigned int semaphore_value, unsigned int multiplier_value); Remarks Sets the semaphore value and multiplier value of the nominated semaphore. (Multiplier value is the number of signals on the semaphore generated by a single signal call on the semaphore.) Parameters semaphore_number: The number by which the semaphore to be affected is known. semaphore_value: The new count value of the semaphore. multiplier_value: The new value of the semaphore's multiplier. Return value None. reset_timer __________________________________________________________________ PC_UNOS Reference Manual Page 41 of 56 $Revision:: 1.0$