Subversion Repositories HelenOS

Rev

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

Rev 1787 Rev 2022
Line 47... Line 47...
47
 
47
 
48
static void consumer(void *arg);
48
static void consumer(void *arg);
49
static void producer(void *arg);
49
static void producer(void *arg);
50
static void failed(void);
50
static void failed(void);
51
 
51
 
52
void producer(void *arg)
52
static void producer(void *arg)
53
{
53
{
54
    thread_detach(THREAD); 
54
    thread_detach(THREAD); 
55
 
55
 
56
    waitq_sleep(&can_start);
56
    waitq_sleep(&can_start);
57
       
57
       
Line 59... Line 59...
59
    atomic_inc(&items_produced);
59
    atomic_inc(&items_produced);
60
    thread_usleep(250);
60
    thread_usleep(250);
61
    semaphore_up(&sem);
61
    semaphore_up(&sem);
62
}
62
}
63
 
63
 
64
void consumer(void *arg)
64
static void consumer(void *arg)
65
{
65
{
66
    thread_detach(THREAD); 
66
    thread_detach(THREAD); 
67
   
67
   
68
    waitq_sleep(&can_start);
68
    waitq_sleep(&can_start);
69
   
69
   
Line 71... Line 71...
71
    atomic_inc(&items_consumed);
71
    atomic_inc(&items_consumed);
72
    thread_usleep(500);
72
    thread_usleep(500);
73
    semaphore_up(&sem);
73
    semaphore_up(&sem);
74
}
74
}
75
 
75
 
76
void failed(void)
76
static void failed(void)
77
{
77
{
78
    printf("Test failed prematurely.\n");
78
    printf("Test failed prematurely.\n");
79
    thread_exit();
79
    thread_exit();
80
}
80
}
81
 
81
 
82
void test(void)
82
void test_semaphore1(void)
83
{
83
{
84
    int i, j, k;
84
    int i, j, k;
85
    int consumers, producers;
85
    int consumers, producers;
86
   
86
   
87
    printf("Semaphore test #1\n");
87
    printf("Semaphore test #1\n");