Subversion Repositories HelenOS-historic

Rev

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

Rev 1 Rev 387
Line 24... Line 24...
24
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
 */
27
 */
28
 
28
 
29
#include <synch/synch.h>
-
 
30
#include <synch/condvar.h>
29
#include <synch/condvar.h>
31
#include <synch/mutex.h>
30
#include <synch/mutex.h>
32
#include <synch/waitq.h>
31
#include <synch/waitq.h>
-
 
32
#include <synch/synch.h>
33
 
33
 
-
 
34
/** Initialize condition variable
-
 
35
 *
-
 
36
 * Initialize condition variable.
-
 
37
 *
-
 
38
 * @param cv Condition variable.
-
 
39
 */
34
void condvar_initialize(condvar_t *cv)
40
void condvar_initialize(condvar_t *cv)
35
{
41
{
36
    waitq_initialize(&cv->wq);
42
    waitq_initialize(&cv->wq);
37
}
43
}
38
 
44
 
-
 
45
/** Signal the condition has become true
-
 
46
 *
-
 
47
 * Signal the condition has become true
-
 
48
 * to the first waiting thread by waking it up.
-
 
49
 *
-
 
50
 * @param Condition variable.
-
 
51
 */
39
void condvar_signal(condvar_t *cv)
52
void condvar_signal(condvar_t *cv)
40
{
53
{
41
    waitq_wakeup(&cv->wq, WAKEUP_FIRST);
54
    waitq_wakeup(&cv->wq, WAKEUP_FIRST);
42
}
55
}
43
 
56
 
-
 
57
/** Signal the condition has become true
-
 
58
 *
-
 
59
 * Signal the condition has become true
-
 
60
 * to all waiting threads by waking them up.
-
 
61
 *
-
 
62
 * @param Condition variable.
-
 
63
 */
44
void condvar_broadcast(condvar_t *cv)
64
void condvar_broadcast(condvar_t *cv)
45
{
65
{
46
    waitq_wakeup(&cv->wq, WAKEUP_ALL);
66
    waitq_wakeup(&cv->wq, WAKEUP_ALL);
47
}
67
}
48
 
68
 
-
 
69
/** Wait for the condition becoming true
-
 
70
 *
-
 
71
 * Wait for the condition becoming true.
-
 
72
 *
-
 
73
 * @param Condition variable.
-
 
74
 */
49
int _condvar_wait_timeout(condvar_t *cv, mutex_t *mtx, __u32 usec, int trywait)
75
int _condvar_wait_timeout(condvar_t *cv, mutex_t *mtx, __u32 usec, int trywait)
50
{
76
{
51
    int rc;
77
    int rc;
52
 
78
 
53
    mutex_unlock(mtx);
79
    mutex_unlock(mtx);