CNDP 22.08.0
Loading...
Searching...
No Matches
cne_thread.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright (c) 2020-2022 Intel Corporation
3 */
4
5#ifndef _CNE_THREAD_H_
6#define _CNE_THREAD_H_
7
20// IWYU pragma: no_include "thread_private.h"
21#include <stdio.h> // for FILE
22#include <pthread.h>
23#include <cne_common.h> // for CNDP_API, CNE_STD_C11
24#include <stdint.h> // for uint16_t, uint64_t, uint8_t
25#include <uid.h>
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
31#define THREAD_WAIT_FOREVER 0
32#define THREAD_DEFAULT_TIMEOUT 1000 // 1ms timeout
33#define THREAD_DEFAULT_NAME "Initial-thread"
34
35typedef void *thd_t;
36
37#ifndef _THREAD_PRIVATE_H_
38/* Define the function prototype if pubicly included */
39typedef void (*thd_func_t)(void *);
40#endif
41
43#define DISPLAY_FLAG 0x00
44#define RX_ONLY_FLAG 0x01
45#define TX_ONLY_FLAG 0x02
46#define RXTX_FLAG (RX_ONLY_FLAG | TX_ONLY_FLAG)
47
48typedef union thread_cfg {
49 uint64_t data;
50 void *arg;
51
53 struct {
54 uint16_t core;
55 uint16_t pid;
56 uint16_t qid;
57 uint8_t flags;
58 uint8_t pad0;
59 };
60} thread_cfg_t;
61
65CNDP_API int thread_id(void);
66
75CNDP_API thd_t thread_get(int tidx);
76
89CNDP_API int thread_create(const char *name, thd_func_t func, void *arg);
90
102CNDP_API int thread_register(const char *name, uint64_t pid);
103
112CNDP_API int thread_unregister(int tidx);
113
127CNDP_API int thread_wait(int tid, unsigned int checks, unsigned int usec);
128
142CNDP_API int thread_wait_all(unsigned int checks, unsigned int usec, int skip);
143
152CNDP_API int thread_stop_running(int tidx);
153
162CNDP_API int thread_running(int tidx);
163
174CNDP_API int thread_set_private(int tidx, void *priv_);
175
184CNDP_API void *thread_get_private(int tidx);
185
189CNDP_API int thread_set_affinity(int cpu);
190
199CNDP_API const char *thread_name(int tidx);
200
207CNDP_API void thread_dump(FILE *f);
208
209#ifdef __cplusplus
210}
211#endif
212
213#endif /* _CNE_THREAD_H_ */
#define CNE_STD_C11
Definition cne_common.h:91
CNDP_API thd_t thread_get(int tidx)
CNDP_API int thread_set_private(int tidx, void *priv_)
CNDP_API int thread_create(const char *name, thd_func_t func, void *arg)
CNDP_API int thread_wait_all(unsigned int checks, unsigned int usec, int skip)
CNDP_API int thread_running(int tidx)
CNDP_API int thread_set_affinity(int cpu)
CNDP_API int thread_unregister(int tidx)
CNDP_API const char * thread_name(int tidx)
CNDP_API void * thread_get_private(int tidx)
CNDP_API void thread_dump(FILE *f)
CNDP_API int thread_stop_running(int tidx)
CNDP_API int thread_wait(int tid, unsigned int checks, unsigned int usec)
CNDP_API int thread_register(const char *name, uint64_t pid)
void * thd_t
Definition cne_thread.h:35
void(*) thd_func_t(void *)
Definition cne_thread.h:39
CNDP_API int thread_id(void)