~lttng/urcu/trunk

« back to all changes in this revision

Viewing changes to urcu-call-rcu.h

  • Committer: Mathieu Desnoyers
  • Author(s): Paul E. McKenney
  • Date: 2011-03-09 02:48:49 UTC
  • Revision ID: git-v1:b57aee663af988b7f686c076ce6aef2a0d2487c8
Add call_rcu() interface

Adds call_rcu(), with RCU threads to invoke the callbacks.  By default,
there will be one such RCU thread per process, created the first time
that call_rcu() is invoked.  On systems supporting sched_getcpu(), it
is possible to create one RCU thread per CPU by calling
create_all_cpu_call_rcu_data().

This version includes feedback from Mathieu Desnoyers.

Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef _URCU_CALL_RCU_H
 
2
#define _URCU_CALL_RCU_H
 
3
 
 
4
/*
 
5
 * urcu-call-rcu.h
 
6
 *
 
7
 * Userspace RCU header - deferred execution
 
8
 *
 
9
 * Copyright (c) 2009 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
 
10
 * Copyright (c) 2009 Paul E. McKenney, IBM Corporation.
 
11
 *
 
12
 * LGPL-compatible code should include this header with :
 
13
 *
 
14
 * #define _LGPL_SOURCE
 
15
 * #include <urcu-defer.h>
 
16
 *
 
17
 * This library is free software; you can redistribute it and/or
 
18
 * modify it under the terms of the GNU Lesser General Public
 
19
 * License as published by the Free Software Foundation; either
 
20
 * version 2.1 of the License, or (at your option) any later version.
 
21
 *
 
22
 * This library is distributed in the hope that it will be useful,
 
23
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
24
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
25
 * Lesser General Public License for more details.
 
26
 *
 
27
 * You should have received a copy of the GNU Lesser General Public
 
28
 * License along with this library; if not, write to the Free Software
 
29
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
30
 */
 
31
 
 
32
#include <stdlib.h>
 
33
#include <pthread.h>
 
34
 
 
35
#include <urcu/wfqueue.h>
 
36
 
 
37
#ifdef __cplusplus
 
38
extern "C" {
 
39
#endif
 
40
 
 
41
/* Note that struct call_rcu_data is opaque to callers. */
 
42
 
 
43
struct call_rcu_data;
 
44
 
 
45
/* Flag values. */
 
46
 
 
47
#define URCU_CALL_RCU_RT        0x1
 
48
#define URCU_CALL_RCU_RUNNING   0x2
 
49
 
 
50
/*
 
51
 * The rcu_head data structure is placed in the structure to be freed
 
52
 * via call_rcu().
 
53
 */
 
54
 
 
55
struct rcu_head {
 
56
        struct cds_wfq_node next;
 
57
        void (*func)(struct rcu_head *head);
 
58
};
 
59
 
 
60
/*
 
61
 * Exported functions
 
62
 */
 
63
void call_rcu_data_init(struct call_rcu_data **crdpp, unsigned long flags);
 
64
struct call_rcu_data *get_cpu_call_rcu_data(int cpu);
 
65
pthread_t get_call_rcu_thread(struct call_rcu_data *crdp);
 
66
struct call_rcu_data *create_call_rcu_data(unsigned long flags);
 
67
int set_cpu_call_rcu_data(int cpu, struct call_rcu_data *crdp);
 
68
struct call_rcu_data *get_default_call_rcu_data(void);
 
69
struct call_rcu_data *get_call_rcu_data(void);
 
70
struct call_rcu_data *get_thread_call_rcu_data(void);
 
71
void set_thread_call_rcu_data(struct call_rcu_data *crdp);
 
72
int create_all_cpu_call_rcu_data(unsigned long flags);
 
73
void call_rcu(struct rcu_head *head,
 
74
              void (*func)(struct rcu_head *head));
 
75
 
 
76
#ifdef __cplusplus 
 
77
}
 
78
#endif
 
79
 
 
80
#endif /* _URCU_CALL_RCU_H */