Coda Distributed File System
lwp.private_pt.h
Go to the documentation of this file.
1/* BLURB lgpl
2
3 Coda File System
4 Release 8
5
6 Copyright (c) 1987-2021 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
16#*/
17
18#ifndef _LWP_PRIVATE_H_
19#define _LWP_PRIVATE_H_
20
21#include <pthread.h>
22#include <semaphore.h>
23#include <stdio.h>
24
25#include "dllist.h"
26
27/* rocks are useful. you can, for instance, hide neat things under them */
28struct rock {
29 int tag;
30 char *value;
31};
32
33struct lwp_pcb {
34 pthread_t thread; /* thread id */
35 struct list_head list; /* list of all threads */
36
40
41 char *name; /* ASCII name */
42
43 void (*func)(void *); /* entry point */
44 void *parm; /* parameters */
45
46#define MAXROCKS 8 /* max. # of rocks per LWP */
47 int nrocks; /* rocks in use */
48 struct rock rock[MAXROCKS]; /* and the rocks themselves */
49
50 sem_t waitq; /* used by QWait/QSignal */
51
52 pthread_cond_t event; /* used by INTERNALSIGNAL/MWait */
53 int eventcnt; /* # of events in the evlist */
54 int waitcnt; /* # of events we wait for */
55 int evsize; /* size of the evlist */
56 char **evlist; /* list of events we wait for */
57};
58
59void lwp_JOIN(PROCESS pid);
60void lwp_LEAVE(PROCESS pid);
61void lwp_YIELD(PROCESS pid);
62int lwp_threads_waiting(void);
63
64/* logging classes */
65#define LWP_DBG_LOCKS 1
66
67extern int lwp_loglevel;
68extern FILE *lwp_logfile;
69
70#define lwp_dbg(class, msg...) \
71 do { \
72 if (lwp_loglevel & class) { \
73 fprintf(lwp_logfile, ##msg); \
74 fflush(lwp_logfile); \
75 } \
76 } while (0);
77
78#define lwp_mutex_lock(lock) \
79 pthread_cleanup_push((void (*)(void *))pthread_mutex_unlock, \
80 (void *)(lock)); \
81 pthread_mutex_lock(lock)
82
83#define lwp_mutex_unlock(lock) pthread_cleanup_pop(1)
84
85#endif /* _LWP_PRIVATE_H_ */
int lwp_threads_waiting(void)
Definition: lwp_pt.c:94
int lwp_loglevel
Definition: lwp_pt.c:42
void lwp_YIELD(PROCESS pid)
Definition: lwp_pt.c:116
void lwp_LEAVE(PROCESS pid)
Definition: lwp_pt.c:105
void lwp_JOIN(PROCESS pid)
FILE * lwp_logfile
Definition: lwp_pt.c:41
#define MAXROCKS
Definition: lwp.private_pt.h:46
Definition: dllist.h:24
Definition: lwp.private_pt.h:33
int concurrent
Definition: lwp.private_pt.h:37
pthread_t thread
Definition: lwp.private_pt.h:34
int priority
Definition: lwp.private_pt.h:39
sem_t waitq
Definition: lwp.private_pt.h:50
pthread_cond_t event
Definition: lwp.private_pt.h:52
void * parm
Definition: lwp.private_pt.h:44
int eventcnt
Definition: lwp.private_pt.h:53
int waitcnt
Definition: lwp.private_pt.h:54
struct list_head list
Definition: lwp.private_pt.h:35
int nrocks
Definition: lwp.private_pt.h:47
char ** evlist
Definition: lwp.private_pt.h:56
char * name
Definition: lwp.private_pt.h:41
void(* func)(void *)
Definition: lwp.private_pt.h:43
int waiting
Definition: lwp.private_pt.h:38
int evsize
Definition: lwp.private_pt.h:55
Definition: lwp.private_pt.h:28
int tag
Definition: lwp.private_pt.h:29
char * value
Definition: lwp.private_pt.h:30