Subversion Repositories HelenOS-historic

Rev

Rev 382 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 382 Rev 404
Line 106... Line 106...
106
 *
106
 *
107
 * This function is really basic in that other functions as waitq_sleep()
107
 * This function is really basic in that other functions as waitq_sleep()
108
 * and all the *_timeout() functions use it.
108
 * and all the *_timeout() functions use it.
109
 *
109
 *
110
 * @param wq Pointer to wait queue.
110
 * @param wq Pointer to wait queue.
111
 * @param usec Timeout value in microseconds.
111
 * @param usec Timeout in microseconds.
112
 * @param nonblocking Controls whether only a conditional sleep
112
 * @param nonblocking Blocking vs. non-blocking operation mode switch.
113
 *        (non-blocking sleep) is called for when the usec argument is 0.
-
 
114
 *
113
 *
-
 
114
 * If usec is greater than zero, regardless of the value of @nonblocking,
115
 * Relation between 'usec' and 'nonblocking' is described by this table:
115
 * the call will not return until either timeout or wakeup comes.
116
 *
116
 *
117
 * usec | nonblocking | what happens if there is no missed_wakeup
117
 * If usec is zero and nonblocking is zero (false), the call
118
 * -----+-------------+--------------------------------------------
-
 
119
 *  0   | 0       | blocks without timeout until wakeup
118
 * will not return until wakeup comes.
-
 
119
 *
120
 *  0   | <> 0        | immediately returns ESYNCH_WOULD_BLOCK
120
 * If usec is zero and nonblocking is non-zero (true), the call will
121
 *  > 0 | x       | blocks with timeout until timeout or wakeup
121
 * immediately return, reporting either success or failure.
122
 *
122
 *
123
 * @return Returns one of: ESYNCH_WOULD_BLOCK, ESYNCH_TIMEOUT,
123
 * @return Returns one of: ESYNCH_WOULD_BLOCK, ESYNCH_TIMEOUT,
124
 *         ESYNCH_OK_ATOMIC, ESYNCH_OK_BLOCKED.
124
 *         ESYNCH_OK_ATOMIC, ESYNCH_OK_BLOCKED.
125
 *
125
 *
-
 
126
 * ESYNCH_WOULD_BLOCK means that the sleep failed because at the time
126
 * Meaning of the return values is described by the following chart:
127
 * of the call there was no pending wakeup.
-
 
128
 *
-
 
129
 * ESYNCH_TIMEOUT means that the sleep timed out.
127
 *
130
 *
128
 * ESYNCH_WOULD_BLOCK   Sleep failed because at the time of the call,
131
 * ESYNCH_OK_ATOMIC means that the sleep succeeded and that there was
129
 *          there was no pending wakeup.
132
 * a pending wakeup at the time of the call. The caller was not put
130
 * ESYNCH_TIMEOUT   Sleep timed out.
133
 * asleep at all.
-
 
134
 *
131
 * ESYNCH_OK_ATOMIC     Sleep succeeded; at the time of the call,
135
 * ESYNCH_OK_BLOCKED means that the sleep succeeded; the full sleep was
132
 *          where was a pending wakeup.
136
 * attempted.
133
 * ESYNCH_OK_BLOCKED    Sleep succeeded; the full sleep was attempted.
-
 
134
 */
137
 */
135
int waitq_sleep_timeout(waitq_t *wq, __u32 usec, int nonblocking)
138
int waitq_sleep_timeout(waitq_t *wq, __u32 usec, int nonblocking)
136
{
139
{
137
    volatile pri_t pri; /* must be live after context_restore() */
140
    volatile pri_t pri; /* must be live after context_restore() */
138
   
141