CNDP
22.08.0
|
#include <stdio.h>
#include <pthread.h>
#include <cne_common.h>
#include <stdint.h>
#include <uid.h>
Go to the source code of this file.
Typedefs | |
typedef void * | thd_t |
typedef void(* | thd_func_t) (void *) |
Functions | |
CNDP_API int | thread_id (void) |
CNDP_API thd_t | thread_get (int tidx) |
CNDP_API int | thread_create (const char *name, thd_func_t func, void *arg) |
CNDP_API int | thread_register (const char *name, uint64_t pid) |
CNDP_API int | thread_unregister (int tidx) |
CNDP_API int | thread_wait (int tid, unsigned int checks, unsigned int usec) |
CNDP_API int | thread_wait_all (unsigned int checks, unsigned int usec, int skip) |
CNDP_API int | thread_stop_running (int tidx) |
CNDP_API int | thread_running (int tidx) |
CNDP_API int | thread_set_private (int tidx, void *priv_) |
CNDP_API void * | thread_get_private (int tidx) |
CNDP_API int | thread_set_affinity (int cpu) |
CNDP_API const char * | thread_name (int tidx) |
CNDP_API void | thread_dump (FILE *f) |
CNE Thread
This library provides the thread management service.
This library provides an interface to create, register, set affinity and schedule a thread. Also support the thread id query ops and debug ops.
See the CNE architecture documentation for more information about the design of this library.
Definition in file cne_thread.h.
typedef void* thd_t |
Thread data handle, opaque value
Definition at line 35 of file cne_thread.h.
typedef void(* thd_func_t) (void *) |
Flags used to determine what type of thread Rx/Tx or Rx or Tx only
Definition at line 39 of file cne_thread.h.
CNDP_API int thread_id | ( | void | ) |
Return the thread ID or index value .
CNDP_API thd_t thread_get | ( | int | tidx | ) |
Returns the thd_t pointer give the thread IDX value.
tidx | The thread index value |
CNDP_API int thread_create | ( | const char * | name, |
thd_func_t | func, | ||
void * | arg | ||
) |
Wrapper routine around pthread_create call to help setup CNDP state
name | The name of the thread that will be created. |
func | The function pointer to call when thread is started. |
arg | The argument passed to the function |
CNDP_API int thread_register | ( | const char * | name, |
uint64_t | pid | ||
) |
Register a thread name and pid value, returning a thread index. Obtains a thread index value unique to this thread.
name | The name of the thread |
pid | The thread identifier value, can be 0 if not required. |
CNDP_API int thread_unregister | ( | int | tidx | ) |
Release a thread index value.
tidx | The thread index value to release. |
CNDP_API int thread_wait | ( | int | tid, |
unsigned int | checks, | ||
unsigned int | usec | ||
) |
Wait for all threads to stop running
tid | The thread id to wait on to complete |
checks | Number of check to attempt, if zero wait forever. |
usec | Number of micro-seconds to wait between checks. |
CNDP_API int thread_wait_all | ( | unsigned int | checks, |
unsigned int | usec, | ||
int | skip | ||
) |
Wait for all threads to stop running
checks | Number of check to attempt, if zero wait forever. |
usec | Number of micro-seconds to wait between checks. |
skip | Skip the first initial thread. |
CNDP_API int thread_stop_running | ( | int | tidx | ) |
Stop a thread running by clearing the running flag
tidx | Clear the running flag for the thread index value, if -1 then stop self |
CNDP_API int thread_running | ( | int | tidx | ) |
Return the state of the thread.
tidx | return the running flag for the thread index value, if -1 then self |
CNDP_API int thread_set_private | ( | int | tidx, |
void * | priv_ | ||
) |
Set a user specific private value or pointer.
tidx | The thread index to store the private value. |
priv_ | The void pointer value to store in the thread state struct. |
CNDP_API void* thread_get_private | ( | int | tidx | ) |
Returns the thread private data stored with thread_set_private()
tidx | The thread index value to return the private value |
CNDP_API int thread_set_affinity | ( | int | cpu | ) |
Set the CPU affinity for the current thread.
CNDP_API const char* thread_name | ( | int | tidx | ) |
Return thread name.
tidx | If tidx is -1 then return current thread name, otherwise tidx name. |
CNDP_API void thread_dump | ( | FILE * | f | ) |
Dump out all threads currently active/allocated
f | The file pointer to write the text output or NULL if stdout |