Changeset View
Changeset View
Standalone View
Standalone View
sys/sys/resource.h
Show First 20 Lines • Show All 57 Lines • ▼ Show 20 Lines | |||||
#define PRIO_PROCESS 0 | #define PRIO_PROCESS 0 | ||||
#define PRIO_PGRP 1 | #define PRIO_PGRP 1 | ||||
#define PRIO_USER 2 | #define PRIO_USER 2 | ||||
/* | /* | ||||
* Resource utilization information. | * Resource utilization information. | ||||
* | * | ||||
* All fields are only modified by curthread and | * All fields are only modified by curthread and | ||||
* no locks are required to read. | * no locks are required to read, except those marked | ||||
* (a), which are accessed with atomics. | |||||
*/ | */ | ||||
#define RUSAGE_SELF 0 | #define RUSAGE_SELF 0 | ||||
#define RUSAGE_CHILDREN -1 | #define RUSAGE_CHILDREN -1 | ||||
#define RUSAGE_THREAD 1 | #define RUSAGE_THREAD 1 | ||||
struct rusage { | struct rusage { | ||||
struct timeval ru_utime; /* user time used */ | struct timeval ru_utime; /* user time used */ | ||||
struct timeval ru_stime; /* system time used */ | struct timeval ru_stime; /* system time used */ | ||||
long ru_maxrss; /* max resident set size */ | long ru_maxrss; /* max resident set size */ | ||||
#define ru_first ru_ixrss | #define ru_first ru_ixrss | ||||
long ru_ixrss; /* integral shared memory size */ | long ru_ixrss; /* integral shared memory size */ | ||||
long ru_idrss; /* integral unshared data " */ | long ru_idrss; /* integral unshared data " */ | ||||
long ru_isrss; /* integral unshared stack " */ | long ru_isrss; /* integral unshared stack " */ | ||||
long ru_minflt; /* page reclaims */ | long ru_minflt; /* page reclaims */ | ||||
long ru_majflt; /* page faults */ | long ru_majflt; /* page faults */ | ||||
long ru_nswap; /* swaps */ | long ru_nswap; /* swaps */ | ||||
long ru_inblock; /* block input operations */ | long ru_inblock; /* (a) block input operations */ | ||||
long ru_oublock; /* block output operations */ | long ru_oublock; /* (a) block output operations */ | ||||
long ru_msgsnd; /* messages sent */ | long ru_msgsnd; /* (a) messages sent */ | ||||
long ru_msgrcv; /* messages received */ | long ru_msgrcv; /* (a) messages received */ | ||||
long ru_nsignals; /* signals received */ | long ru_nsignals; /* signals received */ | ||||
long ru_nvcsw; /* voluntary context switches */ | long ru_nvcsw; /* voluntary context switches */ | ||||
long ru_nivcsw; /* involuntary " */ | long ru_nivcsw; /* involuntary " */ | ||||
#define ru_last ru_nivcsw | #define ru_last ru_nivcsw | ||||
}; | }; | ||||
#if __BSD_VISIBLE | #if __BSD_VISIBLE | ||||
struct __wrusage { | struct __wrusage { | ||||
▲ Show 20 Lines • Show All 74 Lines • ▼ Show 20 Lines | |||||
#define CP_SYS 2 | #define CP_SYS 2 | ||||
#define CP_INTR 3 | #define CP_INTR 3 | ||||
#define CP_IDLE 4 | #define CP_IDLE 4 | ||||
#define CPUSTATES 5 | #define CPUSTATES 5 | ||||
#endif /* __BSD_VISIBLE */ | #endif /* __BSD_VISIBLE */ | ||||
#ifdef _KERNEL | #ifdef _KERNEL | ||||
#define RU_ATOMIC_INC(v) atomic_add_long(&(v), 1) | |||||
asomers: I think it's good style to load these variables using atomic ops if you're going to store them… | |||||
#define RU_ATOMIC_ADD(v, d) atomic_add_long(&(v), (d)) | |||||
extern struct loadavg averunnable; | extern struct loadavg averunnable; | ||||
void read_cpu_time(long *cp_time); /* Writes array of CPUSTATES */ | void read_cpu_time(long *cp_time); /* Writes array of CPUSTATES */ | ||||
#else | #else | ||||
__BEGIN_DECLS | __BEGIN_DECLS | ||||
/* XXX 2nd arg to [gs]etpriority() should be an id_t */ | /* XXX 2nd arg to [gs]etpriority() should be an id_t */ | ||||
Show All 9 Lines |
I think it's good style to load these variables using atomic ops if you're going to store them that way, even if the assembly code will be the same. You should define RU_ATOMIC_LOAD and use it everywhere these variables are read. And that includes the struct copy in the penultimate line of rufetchadd.