Coda Distributed File System
rvm_lwp.h
Go to the documentation of this file.
1/* BLURB lgpl
2
3 Coda File System
4 Release 8
5
6 Copyright (c) 1987-2025 Carnegie Mellon University
7 Additional copyrights listed below
8
9This code is distributed "AS IS" without warranty of any kind under
10the terms of the GNU Library General Public Licence Version 2, as
11shown in the file LICENSE. The technical and financial contributors to
12Coda are listed in the file CREDITS.
13
14 Additional copyrights
15 none currently
16
17#*/
18
19/* LWP compatibility for RVM */
20
21#include <lwp/lwp.h>
22#include <lwp/lock.h>
23
24#define RVM_STACKSIZE 1024 * 16
25#define BOGUSCODE (BOGUS_USE_OF_CTHREADS) /* force compilation error */
26
27#define RVM_MUTEX struct Lock
28#define RVM_CONDITION char
29#define MUTEX_INITIALIZER { 0, 0, 0, 0 }
30
31/* Supported cthread definitions */
32
33#define cthread_t PROCESS
34static inline PROCESS cthread_fork(void (*fname)(void *), void *arg)
35{
36 PROCESS rvm_lwppid;
38 "rvm_thread", &rvm_lwppid);
39 return rvm_lwppid;
40}
41#define cthread_init() \
42 do { \
43 LWP_Init(LWP_VERSION, LWP_NORMAL_PRIORITY, NULL); \
44 IOMGR_Initialize(); \
45 } while (0)
46#define cthread_uninit(retval) \
47 do { \
48 IOMGR_Finalize(); \
49 LWP_TerminateProcessSupport(); \
50 } while (0)
51#define cthread_exit(retval)
52
53#define cthread_yield() \
54 do { \
55 IOMGR_Poll(); \
56 LWP_DispatchProcess(); \
57 } while (0)
58#define cthread_join(thread) (0)
59
60#define condition_wait(c, m) \
61 do { \
62 ReleaseWriteLock((m)); \
63 LWP_WaitProcess((c)); \
64 ObtainWriteLock((m)); \
65 } while (0)
66#define condition_signal(c) (LWP_SignalProcess((c)))
67#define condition_broadcast(c) (LWP_SignalProcess((c)))
68#define condition_clear(c) /* nop */
69#define condition_init(c) /* nop */
70#define mutex_init(m) (Lock_Init(m))
71#define mutex_clear(m) /* nop */
72#define LOCK_FREE(m) (!WriteLocked(&(m)))
73
74static inline PROCESS cthread_self(void)
75{
76 PROCESS rvm_lwppid;
77 LWP_CurrentProcess(&rvm_lwppid);
78 return rvm_lwppid;
79}
80
81/* synchronization tracing definitions of lock/unlock */
82#ifdef DEBUGRVM
83#define mutex_lock(m) \
84 do { \
85 printf("mutex_lock OL(0x%x)%s:%d...", (m), __FILE__, __LINE__); \
86 ObtainWriteLock((m)); \
87 printf("done\n"); \
88 } while (0)
89#define mutex_unlock(m) \
90 do { \
91 printf("mutex_unlock RL(0x%x)%s:%d...", (m), __FILE__, __LINE__); \
92 ReleaseWriteLock((m)); \
93 printf("done\n"); \
94 } while (0)
95#else /* !DEBUGRVM */
96#define mutex_lock(m) ObtainWriteLock((m))
97#define mutex_unlock(m) ReleaseWriteLock((m))
98#endif /* !DEBUGRVM */
99
100/* Unsupported cthread calls */
101
102#define mutex_alloc() BOGUSCODE
103#define mutex_set_name(m, x) BOGUSCODE
104#define mutex_name(m) BOGUSCODE
105#define mutex_free(m) BOGUSCODE
106
107#define condition_alloc() BOGUSCODE
108#define condition_set_name(c, x) BOGUSCODE
109#define condition_name(c) BOGUSCODE
110#define condition_free(c) BOGUSCODE
111
112#define cthread_detach() BOGUSCODE
113#define cthread_sp() BOGUSCODE
114#define cthread_assoc(id, t) BOGUSCODE
115#define cthread_set_name BOGUSCODE
116#define cthread_name BOGUSCODE
117#define cthread_count() BOGUSCODE
118#define cthread_set_limit BOGUSCODE
119#define cthread_limit() BOGUSCODE
120#define cthread_set_data(t, x) BOGUSCODE
121#define cthread_data(t) BOGUSCODE
#define cthread_fork(func, arg)
Definition: cthreads.h:101
#define cthread_self()
Definition: cthreads.h:111
int LWP_CreateProcess(void(*ep)(void *), int stacksize, int priority, void *parm, const char *name, PROCESS *pid)
Definition: lwp_pt.c:297
#define LWP_NORMAL_PRIORITY
Definition: lwp.h:86
int LWP_CurrentProcess(PROCESS *pid)
Definition: lwp_pt.c:214
#define RVM_STACKSIZE
Definition: rvm_lwp.h:24
Definition: rpc2.h:588
Definition: lwp.private_pt.h:33