Subversion Repositories HelenOS

Rev

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

Rev 2022 Rev 2024
Line 44... Line 44...
44
#define READERS     50
44
#define READERS     50
45
#define WRITERS     50
45
#define WRITERS     50
46
 
46
 
47
static rwlock_t rwlock;
47
static rwlock_t rwlock;
48
 
48
 
49
static SPINLOCK_INITIALIZE(lock);
49
SPINLOCK_INITIALIZE(rw_lock);
50
 
50
 
51
static waitq_t can_start;
51
static waitq_t can_start;
52
 
52
 
53
static uint32_t seed = 0xdeadbeef;
53
static uint32_t seed = 0xdeadbeef;
54
 
54
 
Line 60... Line 60...
60
 
60
 
61
static uint32_t random(uint32_t max)
61
static uint32_t random(uint32_t max)
62
{
62
{
63
    uint32_t rc;
63
    uint32_t rc;
64
 
64
 
65
    spinlock_lock(&lock);  
65
    spinlock_lock(&rw_lock);   
66
    rc = seed % max;
66
    rc = seed % max;
67
    seed = (((seed<<2) ^ (seed>>2)) * 487) + rc;
67
    seed = (((seed<<2) ^ (seed>>2)) * 487) + rc;
68
    spinlock_unlock(&lock);
68
    spinlock_unlock(&rw_lock);
69
    return rc;
69
    return rc;
70
}
70
}
71
 
71
 
72
 
72
 
73
static void writer(void *arg)
73
static void writer(void *arg)