# HG changeset patch # User jlarmour # Date 1057117181 0 # Node ID 111911c5ca9e3b5ed1e63170a1686920253cb13f # Parent 6e9aef716a8bdb4a048fee648d9ccb371cadf91b * doc/kernel.sgml: Document that timeouts for timed functions are absolute, not relative. Also document new semantics for cyg_semaphore_timed_wait() for timeouts in the past. diff --git a/packages/kernel/current/ChangeLog b/packages/kernel/current/ChangeLog --- a/packages/kernel/current/ChangeLog +++ b/packages/kernel/current/ChangeLog @@ -1,3 +1,9 @@ +2003-07-02 Jonathan Larmour + + * doc/kernel.sgml: Document that timeouts for timed functions are + absolute, not relative. Also document new semantics for + cyg_semaphore_timed_wait() for timeouts in the past. + 2003-07-01 Nick Garnett * include/clock.hxx: Made Cyg_Counter::add_alarm() and diff --git a/packages/kernel/current/doc/kernel.sgml b/packages/kernel/current/doc/kernel.sgml --- a/packages/kernel/current/doc/kernel.sgml +++ b/packages/kernel/current/doc/kernel.sgml @@ -3197,10 +3197,17 @@ and the current thread will be suspended some other thread performs a signal or broadcast operation the current thread will be woken up and automatically reclaim ownership of the mutex again, allowing it to examine global state and determine whether or -not the condition is now satisfied. The kernel supplies a variant of -this function, cyg_cond_timed_wait, which can be -used to wait on the condition variable or until some number of clock -ticks have occurred. The mutex will always be reclaimed before +not the condition is now satisfied. + + +The kernel supplies a variant of this function, +cyg_cond_timed_wait, which can be used to wait on +the condition variable or until some number of clock ticks have +occurred. The number of ticks is specified as an absolute, not +relative tick count, and so in order to wait for a relative number of +ticks, the return value of the cyg_current_time() +function should be added to determine the absolute number of ticks. +The mutex will always be reclaimed before cyg_cond_timed_wait returns, regardless of whether it was a result of a signal operation or a timeout. @@ -3380,14 +3387,21 @@ and cyg_semaphore_waitcyg_semaphore_timed_wait is a variant of cyg_semaphore_wait. It can be used to wait until either an event has occurred or a number of clock ticks have happened. -The function returns success if the semaphore wait operation -succeeded, or false if the operation timed out or was aborted by -cyg_thread_release. If support for the real-time +The number of ticks is specified as an absolute, not relative tick +count, and so in order to wait for a relative number of ticks, the +return value of the cyg_current_time() function +should be added to determine the absolute number of ticks. The +function returns success if the semaphore wait operation succeeded, or +false if the operation timed out or was aborted by +cyg_thread_release. +If support for the real-time clock has been removed from the current configuration then this function will not be available. cyg_semaphore_trywait is another variant which will always return immediately rather than block, again returning -success or failure. +success or failure. If cyg_semaphore_timedwait +is given a timeout in the past, it operates like +cyg_semaphore_trywait. cyg_semaphore_peek can be used to get hold of the @@ -3549,7 +3563,11 @@ with different priorities. There are two variants of cyg_mbox_get. The first, cyg_mbox_timed_get will wait until either a message is available or until a number of clock ticks have occurred. -If no message is posted within the timeout then a null pointer will be +The number of ticks is specified as an absolute, not relative tick +count, and so in order to wait for a relative number of ticks, the +return value of the cyg_current_time() function +should be added to determine the absolute number of ticks. If no +message is posted within the timeout then a null pointer will be returned. cyg_mbox_tryget is a non-blocking operation which will either return a message if one is available or a null pointer. @@ -3566,10 +3584,11 @@ receive the message. If the mail box is get operation and a slot is available. The cyg_mbox_timed_put variant imposes a time limit on the put operation, returning false if the operation cannot be -completed within the specified number of clock ticks. The -cyg_mbox_tryput variant is non-blocking, -returning false if there are no free slots available and the message -cannot be posted without blocking. +completed within the specified number of clock ticks and as for +cyg_mbox_timed_get this is an absolute tick +count. The cyg_mbox_tryput variant is +non-blocking, returning false if there are no free slots available and +the message cannot be posted without blocking. There are a further four functions available for examining the current @@ -3773,10 +3792,15 @@ that is currently in a wait operation, t cyg_flag_timed_wait is a variant of cyg_flag_wait which adds a timeout: the wait operation must succeed within the specified number of ticks, or it -will fail with a return value of 0. cyg_flag_poll -is a non-blocking variant: if the wait operation can succeed -immediately it acts like cyg_flag_wait, otherwise -it returns immediately with a value of 0. +will fail with a return value of 0. The number of ticks is specified +as an absolute, not relative tick count, and so in order to wait for a +relative number of ticks, the return value of the +cyg_current_time() function should be added to +determine the absolute number of ticks. +cyg_flag_poll is a non-blocking variant: if the +wait operation can succeed immediately it acts like +cyg_flag_wait, otherwise it returns immediately +with a value of 0. cyg_flag_setbits is called by a producer thread