ngc 1.5.0
 
Loading...
Searching...
No Matches
ngcbSched.h
Go to the documentation of this file.
1
8#ifndef ngcbSched_h
9#define ngcbSched_h
10
11
12
13#ifndef _REENTRANT
14#define _REENTRANT
15#endif
16
17#include <stdio.h>
18#include <stdlib.h>
19#include <unistd.h>
20#include <signal.h>
21#include <string.h>
22#include <errno.h>
23#include <sys/time.h>
24#include <pthread.h>
25
26#include <ngc/core/ngcb.h>
27
28#ifdef __cplusplus
29extern "C" {
30#endif
31
32/*
33 * CPU profiles
34 */
35#ifndef NGC_CCV
36#define NGC_CCV 11
37#endif
38#define ngcbCPU_PROFILE_DMA 1
39#define ngcbCPU_PROFILE_UDP 2
40
41/*
42 * CPU affinity flags
43 */
44#define ngcbCPU_ANY -1
45#define ngcbCPU_SHARED -2
46#define ngcbCPU_HIGH -3
47#define ngcbCPU_EXACT 0x1
48#define ngcbCPU_EXCLUDE 0x2
49
53typedef pthread_t ngcb_thread_t;
54
58typedef struct timespec ngcb_abstime_t;
59
63#define ngcbGetAbsTime(t) clock_gettime(CLOCK_REALTIME, t)
64
68#define ngcbSEM_FAST 0
69
73#define ngcbSEM_CHECKED 1
74
78typedef struct {
79 pthread_mutex_t mutex_v;
80 pthread_cond_t lck;
81 size_t val;
83
87typedef struct {
88 pthread_mutex_t mutex_v;
89 pthread_cond_t lckr;
90 pthread_cond_t lckw;
91 unsigned int val;
92 unsigned char wr;
94
95/*
96 * Priority control
97 */
98#define ngcbPRI_TS 1
99#define ngcbPRI_IA 2
100#define ngcbPRI_RT 3
101#define ngcbTQ_DEF 0
102#define ngcbTQ_NC -1
103#define ngcbTQ_INF -2
104
108extern int ngcbPrio;
109
113int ngcbSetPrio(int priority, int schedClass, int quantum);
114
118int ngcbGetPrio(int *priority, int *schedClass, int *quantum);
119
123void ngcbClockInit(void);
124
130
136
141double ngcbTimeStamp();
142
148uint64_t ngcbTimeStamp64();
149
156int _ngcbClockWait(int fd, int waitTime);
157
161#define ngcbClockWait(fd, waitTime) ngcbMicroSleep(fd, waitTime)
162
163/*
164 * Threads
165 */
166
171int ngcbThrCreate(void *(*startFunc)(void *), void *arg, size_t stack,
172 ngcb_thread_t *thread);
173
177void ngcbThrExit(void *status);
178
182int ngcbThrCancel(ngcb_thread_t thread);
183
187int ngcbThrKill(ngcb_thread_t thread, int sig);
188
192int ngcbThrJoin(ngcb_thread_t thread);
193
198
204
208extern int ngcbCpuProfile;
209
213int ngcbCpuNumCores(void);
214
218int ngcbCpuRT(void);
219
223int ngcbCpu2Thread(ngcb_thread_t thread, int cpu, int flag);
224
228int ngcbCpuAssign(int cpu, int flag);
229
233void ngcbCpuShow(const char *name);
234
238int ngcbCpuDisableLatencyStates(char *erms);
239
243void ngcbCpuResetLatencyStates(int fd);
244
245/*
246 * Semaphores
247 */
248
255int ngcbSemInit(ngcb_sema_t *sp, unsigned int count, int type, void *arg);
256
261
267int ngcbSemLock(ngcb_sema_t *sp);
268
273
280
284int ngcbSemPost(ngcb_sema_t *sp);
285
289int ngcbSemSet(ngcb_sema_t *sp, unsigned int cnt);
290
296int ngcbSemWait(ngcb_sema_t *sp);
297
303size_t ngcbSemWaitCnt(ngcb_sema_t *sp, size_t cnt);
304
313
319
323size_t ngcbSemCnt(ngcb_sema_t *sp);
324
325
326/*
327 * Readers/writer locks
328 */
329
333int ngcbRwLockInit(ngcb_lock_t *rwlp, int type, void *arg);
334
339
347int ngcbRwRdLock(ngcb_lock_t *rwlp);
348
355
363int ngcbRwWrLock(ngcb_lock_t *rwlp);
364
371
382int ngcbRwUnlock(ngcb_lock_t *rwlp);
383
384
385/*
386 * Synchronous multi-threading
387 */
388
393int ngcbProcCreate(void (*calcProcess)(void *), int n, char *erms);
394
401int ngcbProcCreate2(void (*calcProcess)(void *), int n, size_t stack,
402 char *erms);
403
407int ngcbProcWaitStart(int procId);
408
412int ngcbProcWaitTrigger(int procId);
413
417int ngcbProcAck(int procId);
418
422int ngcbProcStart(int setId);
423
427int ngcbProcTrigger(int setId) ;
428
432int ngcbProcWaitAck(int setId);
433
438int ngcbProcSync(int procId);
439
443void ngcbProcJoin(int setId);
444
448void ngcbProcFree(int setId);
449
453#define ngcbPROC_MAX_SET 8
454
458#define ngcbPROC_MAX_PROC 1024
459
463#define ngcbProcId(x) (int)((unsigned long)x & 0xffffffff)
464
468#define ngcbProcNum(x) (int)(x & 0x0000ffff)
469
470#ifdef __cplusplus
471}
472#endif
473
474#endif
int ngcbRwLockDestroy(ngcb_lock_t *rwlp)
Definition ngcbSchedSem.c:308
int ngcbCpuAssign(int cpu, int flag)
Definition ngcbSchedCpu.c:194
ngcb_thread_t ngcbThrId(void)
Definition ngcbSchedThread.c:95
int ngcbProcWaitTrigger(int procId)
Definition ngcbSchedProc.c:372
int ngcbRwRdLock(ngcb_lock_t *rwlp)
Definition ngcbSchedSem.c:334
int _ngcbClockWait(int fd, int waitTime)
Definition ngcbSchedClock.c:131
int ngcbProcStart(int setId)
Definition ngcbSchedProc.c:329
int ngcbCpuDisableLatencyStates(char *erms)
Definition ngcbSchedCpu.c:234
void ngcbCpuResetLatencyStates(int fd)
Definition ngcbSchedCpu.c:255
uint64_t ngcbTimeStamp64()
Definition ngcbSchedClock.c:123
int ngcbPrio
Definition ngcbSchedPrio.c:23
void ngcbThrExit(void *status)
Definition ngcbSchedThread.c:54
int ngcbSemSet(ngcb_sema_t *sp, unsigned int cnt)
Definition ngcbSchedSem.c:142
int ngcbSemLock(ngcb_sema_t *sp)
Definition ngcbSchedSem.c:88
pthread_t ngcb_thread_t
Definition ngcbSched.h:53
int ngcbSemWaitAbsTime(ngcb_sema_t *sp, ngcb_abstime_t *absTime)
Definition ngcbSchedSem.c:198
int ngcbRwUnlock(ngcb_lock_t *rwlp)
Definition ngcbSchedSem.c:443
int ngcbProcAck(int procId)
Definition ngcbSchedProc.c:392
int ngcbRwTryWrLock(ngcb_lock_t *rwlp)
Definition ngcbSchedSem.c:405
void ngcbClockGet(ngcb_time_hr *t)
Definition ngcbSchedClock.c:78
int ngcbSemUnlock(ngcb_sema_t *sp)
Definition ngcbSchedSem.c:96
int ngcbSemPost(ngcb_sema_t *sp)
Definition ngcbSchedSem.c:123
int ngcbRwLockInit(ngcb_lock_t *rwlp, int type, void *arg)
Definition ngcbSchedSem.c:268
int ngcbCpuRT(void)
Definition ngcbSchedCpu.c:32
struct timespec ngcb_abstime_t
Definition ngcbSched.h:58
int ngcbSetPrio(int priority, int schedClass, int quantum)
Definition ngcbSchedPrio.c:74
int ngcbProcTrigger(int setId)
Definition ngcbSchedProc.c:405
int ngcbSemInit(ngcb_sema_t *sp, unsigned int count, int type, void *arg)
Definition ngcbSchedSem.c:19
size_t ngcbSemCnt(ngcb_sema_t *sp)
Definition ngcbSchedSem.c:254
int ngcbProcCreate2(void(*calcProcess)(void *), int n, size_t stack, char *erms)
Definition ngcbSchedProc.c:71
int ngcbCpu2Thread(ngcb_thread_t thread, int cpu, int flag)
Definition ngcbSchedCpu.c:48
int ngcbRwTryRdLock(ngcb_lock_t *rwlp)
Definition ngcbSchedSem.c:353
void ngcbProcFree(int setId)
Definition ngcbSchedProc.c:301
int ngcbThrEqual(ngcb_thread_t t1, ngcb_thread_t t2)
Definition ngcbSchedThread.c:100
int ngcbRwWrLock(ngcb_lock_t *rwlp)
Definition ngcbSchedSem.c:382
void ngcbClockInit(void)
Definition ngcbSchedClock.c:32
int ngcbSemDestroy(ngcb_sema_t *sp)
Definition ngcbSchedSem.c:70
int ngcbSemTryWait(ngcb_sema_t *sp)
Definition ngcbSchedSem.c:223
int ngcbCpuProfile
Definition ngcbSchedCpu.c:22
int ngcbProcCreate(void(*calcProcess)(void *), int n, char *erms)
Definition ngcbSchedProc.c:65
int ngcbSemTryLock(ngcb_sema_t *sp)
Definition ngcbSchedSem.c:104
int ngcbThrKill(ngcb_thread_t thread, int sig)
Definition ngcbSchedThread.c:71
void ngcbClockGetAbs(ngcb_time_hr *t)
Definition ngcbSchedClock.c:40
int ngcbSemWait(ngcb_sema_t *sp)
Definition ngcbSchedSem.c:161
int ngcbProcWaitAck(int setId)
Definition ngcbSchedProc.c:415
int ngcbGetPrio(int *priority, int *schedClass, int *quantum)
Definition ngcbSchedPrio.c:45
void ngcbCpuShow(const char *name)
Definition ngcbSchedCpu.c:200
size_t ngcbSemWaitCnt(ngcb_sema_t *sp, size_t cnt)
Definition ngcbSchedSem.c:177
int ngcbThrJoin(ngcb_thread_t thread)
Definition ngcbSchedThread.c:83
int ngcbCpuNumCores(void)
Definition ngcbSchedCpu.c:25
void ngcbProcJoin(int setId)
Definition ngcbSchedProc.c:319
int ngcbThrCreate(void *(*startFunc)(void *), void *arg, size_t stack, ngcb_thread_t *thread)
Definition ngcbSchedThread.c:19
int ngcbProcWaitStart(int procId)
Definition ngcbSchedProc.c:352
double ngcbTimeStamp()
Definition ngcbSchedClock.c:116
int ngcbThrCancel(ngcb_thread_t thread)
Definition ngcbSchedThread.c:59
int ngcbProcSync(int procId)
Definition ngcbSchedProc.c:430
Definition ngcbSched.h:87
unsigned int val
Definition ngcbSched.h:91
unsigned char wr
Definition ngcbSched.h:92
pthread_mutex_t mutex_v
Definition ngcbSched.h:88
pthread_cond_t lckr
Definition ngcbSched.h:89
pthread_cond_t lckw
Definition ngcbSched.h:90
Definition ngcbSched.h:78
pthread_cond_t lck
Definition ngcbSched.h:80
pthread_mutex_t mutex_v
Definition ngcbSched.h:79
size_t val
Definition ngcbSched.h:81
Definition ngcb.h:208