Subversion Repositories HelenOS

Rev

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

Rev 2050 Rev 2053
Line 36... Line 36...
36
 
36
 
37
#define READERS     50
37
#define READERS     50
38
#define WRITERS     50
38
#define WRITERS     50
39
 
39
 
40
static rwlock_t rwlock;
40
static rwlock_t rwlock;
-
 
41
static bool sh_quiet;
41
 
42
 
42
static void writer(void *arg)
43
static void writer(void *arg)
43
{
44
{
44
 
-
 
45
    thread_detach(THREAD);
45
    if (!sh_quiet)
46
 
-
 
47
    printf("Trying to lock rwlock for writing....\n");    
46
        printf("Trying to lock rwlock for writing....\n");
48
 
47
   
49
    rwlock_write_lock(&rwlock);
48
    rwlock_write_lock(&rwlock);
50
    rwlock_write_unlock(&rwlock);
49
    rwlock_write_unlock(&rwlock);
51
   
50
   
-
 
51
    if (!sh_quiet)
52
    printf("Trying to lock rwlock for reading....\n");     
52
        printf("Trying to lock rwlock for reading....\n");
-
 
53
   
53
    rwlock_read_lock(&rwlock);
54
    rwlock_read_lock(&rwlock);
54
    rwlock_read_unlock(&rwlock);   
55
    rwlock_read_unlock(&rwlock);   
55
    printf("Test passed.\n");
-
 
56
}
56
}
57
 
57
 
58
char * test_rwlock2(bool quiet)
58
char * test_rwlock2(bool quiet)
59
{
59
{
60
    thread_t *thrd;
60
    thread_t *thrd;
-
 
61
    sh_quiet = quiet;
61
   
62
   
62
    rwlock_initialize(&rwlock);
63
    rwlock_initialize(&rwlock);
63
 
64
 
64
    rwlock_read_lock(&rwlock);
65
    rwlock_read_lock(&rwlock);
65
    rwlock_read_lock(&rwlock);
66
    rwlock_read_lock(&rwlock);
Line 77... Line 78...
77
    rwlock_read_unlock(&rwlock);
78
    rwlock_read_unlock(&rwlock);
78
    rwlock_read_unlock(&rwlock);
79
    rwlock_read_unlock(&rwlock);
79
    rwlock_read_unlock(&rwlock);
80
    rwlock_read_unlock(&rwlock);
80
    rwlock_read_unlock(&rwlock);
81
    rwlock_read_unlock(&rwlock);
81
   
82
   
-
 
83
    thread_join(thrd);
-
 
84
    thread_detach(thrd);
-
 
85
   
82
    return NULL;
86
    return NULL;
83
}
87
}