Subversion Repositories HelenOS

Rev

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

Rev 2260 Rev 2265
Line 35... Line 35...
35
#include <synch/rcu.h>
35
#include <synch/rcu.h>
36
#include <synch/waitq.h>
36
#include <synch/waitq.h>
37
#include <arch.h>
37
#include <arch.h>
38
#include <config.h>
38
#include <config.h>
39
#include <arch/types.h>
39
#include <arch/types.h>
40
#include <ddi/tasklet.h>
40
#include <proc/tasklet.h>
41
#include <synch/spinlock.h>
41
#include <synch/spinlock.h>
42
#include <time/delay.h>
42
#include <time/delay.h>
43
#include <panic.h>
43
#include <panic.h>
44
#include <print.h>
44
#include <print.h>
45
 
45
 
46
typedef struct rcu_global
46
typedef struct  {
47
{
-
 
48
    uint32_t current_batch;
47
    uint32_t current_batch;
49
    uint32_t completed_batch;
48
    uint32_t completed_batch;
50
    bool next_batch_waiting;
49
    bool next_batch_waiting;
51
} rcu_global_t;
50
} rcu_global_t;
52
 
51
 
53
typedef struct rcu_callback_list
52
typedef struct rcu_callback_list {
54
{
-
 
55
struct rcu_callback_list* next;
53
    struct rcu_callback_list* next;
56
void (*func)(void*);
54
    void (*func)(void*);
57
void* data;
55
    void* data;
58
bool* cpu_mask;
56
    bool* cpu_mask;
59
} rcu_callback_list_t;
57
} rcu_callback_list_t;
60
 
58
 
61
 
59
 
62
typedef struct rcu_percpu
60
typedef struct {
63
{
-
 
64
    uint32_t current_batch_number;
61
    uint32_t current_batch_number;
65
    uint32_t QS_passed;
62
    uint32_t QS_passed;
66
    bool QS_pending;
63
    bool QS_pending;
67
 
-
 
68
rcu_callback_list_t* next_batch, *current_batch, *done_batch;
64
    rcu_callback_list_t* next_batch, *current_batch, *done_batch;
69
} rcu_percpu_t;
65
} rcu_percpu_t;
70
 
66
 
71
rcu_global_t _rcu_global;
67
rcu_global_t _rcu_global;
72
rcu_percpu_t* _rcu_cpu_lists;
68
rcu_percpu_t* _rcu_cpu_lists;
73
 
69
 
74
void rcu_init(void)
70
void rcu_init(void)
75
{
71
{
76
    _rcu_cpu_lists = malloc(sizeof(rcu_percpu_t)*config.cpu_count,0);
72
    _rcu_cpu_lists = malloc(sizeof(rcu_percpu_t)*config.cpu_count,0);
77
    _rcu_global.completed_batch = -1;
73
    _rcu_global.completed_batch = -1;
78
    _rcu_global.current_batch = -1;
74
    _rcu_global.current_batch = -1;
79
    _rcu_global.next_batch_waiting = -1;
75
    _rcu_global.next_batch_waiting = -1;
80
 
-
 
81
}
76
}
82
 
77
 
83
void rcu_synchronize(void)
78
void rcu_synchronize(void)
84
{
79
{
85
    waitq_t wq;
80
    waitq_t wq;
Line 95... Line 90...
95
 
90
 
96
void rcu_sync_callback(void (*func)(void* data), void* data)
91
void rcu_sync_callback(void (*func)(void* data), void* data)
97
{
92
{
98
    int i;
93
    int i;
99
    rcu_callback_list_t *rd;
94
    rcu_callback_list_t *rd;
100
    rd = malloc(sizeof(rcu_desc), 0);
95
    rd = malloc(sizeof(rcu_callback_list_t), 0);
101
    rd->func = func;
96
    rd->func = func;
102
    rd->data = data;
97
    rd->data = data;
103
    rd->next = NULL;
98
    rd->next = NULL;
104
 
99
 
105
    rd->cpu_mask = malloc (sizeof(bool)*config.cpu_count,0);
100
    rd->cpu_mask = malloc (sizeof(bool)*config.cpu_count,0);
Line 108... Line 103...
108
   
103
   
109
    i = ++(_rcu_global.current_batch);
104
    i = ++(_rcu_global.current_batch);
110
    _rcu_global.next_batch_waiting = true;
105
    _rcu_global.next_batch_waiting = true;
111
 
106
 
112
    rd->next = _rcu_cpu_lists[0].next_batch;
107
    rd->next = _rcu_cpu_lists[0].next_batch;
113
    for (i=0;i<config.cpu_count;i++)
108
    for (i=0;i<config.cpu_count;i++) {
114
    {
-
 
115
        _rcu_cpu_lists[i].next_batch = rd;
109
        _rcu_cpu_lists[i].next_batch = rd;
116
        _rcu_cpu_lists[i].QS_pending = true;
110
        _rcu_cpu_lists[i].QS_pending = true;
117
 
-
 
118
    }
111
    }
119
 
112
 
120
    //TODO:tasklet, after_thread_ran, polishing
113
    //TODO:tasklet, after_thread_ran, polishing
121
}
114
}
122
 
115