Merging test-x310, ci-dev-nr-add-gnb-nr-ur-uspr-testing and nr-mimo-mode-clean branches
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
int T_stdout;
|
||||
|
||||
void exit_function(const char *file, const char *function, const int line, const char *s) {
|
||||
}
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
|
||||
#include <intertask_interface.h>
|
||||
#include <common/utils/system.h>
|
||||
|
||||
typedef struct timer_elm_s {
|
||||
timer_type_t type; ///< Timer type
|
||||
@@ -263,7 +264,8 @@ extern "C" {
|
||||
pthread_mutex_unlock (&t->queue_cond_lock);
|
||||
}
|
||||
|
||||
void itti_poll_msg(task_id_t task_id, MessageDef **received_msg) {
|
||||
void itti_poll_msg(task_id_t task_id, MessageDef **received_msg)
|
||||
{
|
||||
//reception of one message, non-blocking
|
||||
task_list_t *t=&tasks[task_id];
|
||||
pthread_mutex_lock(&t->queue_cond_lock);
|
||||
@@ -278,24 +280,13 @@ extern "C" {
|
||||
pthread_mutex_unlock (&t->queue_cond_lock);
|
||||
}
|
||||
|
||||
int itti_create_task(task_id_t task_id, void *(*start_routine)(void *), void *args_p) {
|
||||
int itti_create_task(task_id_t task_id,
|
||||
void *(*start_routine)(void *),
|
||||
void *args_p)
|
||||
{
|
||||
task_list_t *t=&tasks[task_id];
|
||||
AssertFatal ( pthread_create (&t->thread, NULL, start_routine, args_p) ==0,
|
||||
"Thread creation for task %d failed!\n", task_id);
|
||||
pthread_setname_np( t->thread, itti_get_task_name(task_id) );
|
||||
threadCreate (&t->thread, start_routine, args_p, (char*)itti_get_task_name(task_id),-1,OAI_PRIORITY_RT);
|
||||
LOG_I(TMR,"Created Posix thread %s\n", itti_get_task_name(task_id) );
|
||||
#if 1 // BMC test RT prio
|
||||
{
|
||||
int policy;
|
||||
struct sched_param sparam;
|
||||
memset(&sparam, 0, sizeof(sparam));
|
||||
sparam.sched_priority = sched_get_priority_max(SCHED_FIFO)-10;
|
||||
policy = SCHED_FIFO ;
|
||||
if (pthread_setschedparam(t->thread, policy, &sparam) != 0) {
|
||||
LOG_E(TMR,"task %s : Failed to set pthread priority\n", itti_get_task_name(task_id) );
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -303,14 +294,19 @@ extern "C" {
|
||||
pthread_exit (NULL);
|
||||
}
|
||||
|
||||
void itti_terminate_tasks(task_id_t task_id) {
|
||||
void itti_terminate_tasks(task_id_t task_id)
|
||||
{
|
||||
// Sends Terminate signals to all tasks.
|
||||
itti_send_terminate_message (task_id);
|
||||
usleep(100*1000); // Allow the tasks to receive the message before going returning to main thread
|
||||
}
|
||||
|
||||
int itti_init(task_id_t task_max, thread_id_t thread_max, MessagesIds messages_id_max, const task_info_t *tasks_info,
|
||||
const message_info_t *messages_info) {
|
||||
int itti_init(task_id_t task_max,
|
||||
thread_id_t thread_max,
|
||||
MessagesIds messages_id_max,
|
||||
const task_info_t *tasks_info,
|
||||
const message_info_t *messages_info)
|
||||
{
|
||||
AssertFatal(TASK_MAX<UINT16_MAX, "Max itti tasks");
|
||||
|
||||
for(int i=0; i<task_max; ++i) {
|
||||
@@ -335,7 +331,8 @@ extern "C" {
|
||||
int32_t instance,
|
||||
timer_type_t type,
|
||||
void *timer_arg,
|
||||
long *timer_id) {
|
||||
long *timer_id)
|
||||
{
|
||||
task_list_t *t=&tasks[task_id];
|
||||
|
||||
do {
|
||||
@@ -369,7 +366,8 @@ extern "C" {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int timer_remove(long timer_id) {
|
||||
int timer_remove(long timer_id)
|
||||
{
|
||||
task_id_t task_id=(task_id_t)(timer_id&0xffff);
|
||||
int ret;
|
||||
pthread_mutex_lock (&tasks[task_id].queue_cond_lock);
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
#ifndef __SIMPLE_EXE_H__
|
||||
#define __SIMPLE_EXE_H__
|
||||
#ifndef __USE_GNU
|
||||
#define __USE_GNU
|
||||
#endif
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#include <pthread.h>
|
||||
#include <sched.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <sys/time.h>
|
||||
#include <stdint.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <stdbool.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/tcp.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <common/utils/assertions.h>
|
||||
#include <common/utils/LOG/log.h>
|
||||
#include "common_lib.h"
|
||||
|
||||
#ifdef T
|
||||
#undef T
|
||||
#define T(...)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
+83
-21
@@ -28,13 +28,23 @@
|
||||
* separate process solves this problem.
|
||||
*/
|
||||
|
||||
#define _GNU_SOURCE
|
||||
#include "system.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <pthread.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <pthread.h>
|
||||
#include <common/utils/assertions.h>
|
||||
#include <common/utils/LOG/log.h>
|
||||
#define MAX_COMMAND 4096
|
||||
|
||||
static int command_pipe_read;
|
||||
@@ -50,37 +60,37 @@ static int module_initialized = 0;
|
||||
/* util functions */
|
||||
/********************************************************************/
|
||||
|
||||
static void lock_system(void)
|
||||
{
|
||||
static void lock_system(void) {
|
||||
if (pthread_mutex_lock(&lock) != 0) {
|
||||
printf("pthread_mutex_lock fails\n");
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
static void unlock_system(void)
|
||||
{
|
||||
static void unlock_system(void) {
|
||||
if (pthread_mutex_unlock(&lock) != 0) {
|
||||
printf("pthread_mutex_unlock fails\n");
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
static void write_pipe(int p, char *b, int size)
|
||||
{
|
||||
static void write_pipe(int p, char *b, int size) {
|
||||
while (size) {
|
||||
int ret = write(p, b, size);
|
||||
|
||||
if (ret <= 0) exit(0);
|
||||
|
||||
b += ret;
|
||||
size -= ret;
|
||||
}
|
||||
}
|
||||
|
||||
static void read_pipe(int p, char *b, int size)
|
||||
{
|
||||
static void read_pipe(int p, char *b, int size) {
|
||||
while (size) {
|
||||
int ret = read(p, b, size);
|
||||
|
||||
if (ret <= 0) exit(0);
|
||||
|
||||
b += ret;
|
||||
size -= ret;
|
||||
}
|
||||
@@ -95,14 +105,13 @@ static void read_pipe(int p, char *b, int size)
|
||||
* when the main process exits, because then a "read" on the pipe
|
||||
* will return 0, in which case "read_pipe" exits.
|
||||
*/
|
||||
static void background_system_process(void)
|
||||
{
|
||||
static void background_system_process(void) {
|
||||
int len;
|
||||
int ret;
|
||||
char command[MAX_COMMAND+1];
|
||||
|
||||
while (1) {
|
||||
read_pipe(command_pipe_read, (char*)&len, sizeof(int));
|
||||
read_pipe(command_pipe_read, (char *)&len, sizeof(int));
|
||||
read_pipe(command_pipe_read, command, len);
|
||||
ret = system(command);
|
||||
write_pipe(result_pipe_write, (char *)&ret, sizeof(int));
|
||||
@@ -114,8 +123,7 @@ static void background_system_process(void)
|
||||
/* return -1 on error, 0 on success */
|
||||
/********************************************************************/
|
||||
|
||||
int background_system(char *command)
|
||||
{
|
||||
int background_system(char *command) {
|
||||
int res;
|
||||
int len;
|
||||
|
||||
@@ -125,18 +133,22 @@ int background_system(char *command)
|
||||
}
|
||||
|
||||
len = strlen(command)+1;
|
||||
|
||||
if (len > MAX_COMMAND) {
|
||||
printf("FATAL: command too long. Increase MAX_COMMAND (%d).\n", MAX_COMMAND);
|
||||
printf("command was: '%s'\n", command);
|
||||
abort();
|
||||
}
|
||||
|
||||
/* only one command can run at a time, so let's lock/unlock */
|
||||
lock_system();
|
||||
write_pipe(command_pipe_write, (char*)&len, sizeof(int));
|
||||
write_pipe(command_pipe_write, (char *)&len, sizeof(int));
|
||||
write_pipe(command_pipe_write, command, len);
|
||||
read_pipe(result_pipe_read, (char*)&res, sizeof(int));
|
||||
read_pipe(result_pipe_read, (char *)&res, sizeof(int));
|
||||
unlock_system();
|
||||
|
||||
if (res == -1 || !WIFEXITED(res) || WEXITSTATUS(res) != 0) return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -146,17 +158,16 @@ int background_system(char *command)
|
||||
/* to be called very early by the main processing */
|
||||
/********************************************************************/
|
||||
|
||||
void start_background_system(void)
|
||||
{
|
||||
void start_background_system(void) {
|
||||
int p[2];
|
||||
pid_t son;
|
||||
|
||||
module_initialized = 1;
|
||||
|
||||
if (pipe(p) == -1) {
|
||||
perror("pipe");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
command_pipe_read = p[0];
|
||||
command_pipe_write = p[1];
|
||||
|
||||
@@ -164,10 +175,11 @@ void start_background_system(void)
|
||||
perror("pipe");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
result_pipe_read = p[0];
|
||||
result_pipe_write = p[1];
|
||||
|
||||
son = fork();
|
||||
|
||||
if (son == -1) {
|
||||
perror("fork");
|
||||
exit(1);
|
||||
@@ -181,6 +193,56 @@ void start_background_system(void)
|
||||
|
||||
close(result_pipe_read);
|
||||
close(command_pipe_write);
|
||||
|
||||
background_system_process();
|
||||
}
|
||||
|
||||
|
||||
void threadCreate(pthread_t* t, void * (*func)(void*), void * param, char* name, int affinity, int priority){
|
||||
pthread_attr_t attr;
|
||||
pthread_attr_init(&attr);
|
||||
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
|
||||
pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED);
|
||||
pthread_attr_setschedpolicy(&attr, SCHED_FIFO);
|
||||
struct sched_param sparam={0};
|
||||
sparam.sched_priority = priority;
|
||||
pthread_attr_setschedparam(&attr, &sparam);
|
||||
|
||||
pthread_create(t, &attr, func, param);
|
||||
|
||||
pthread_setname_np(*t, name);
|
||||
if (affinity != -1 ) {
|
||||
cpu_set_t cpuset;
|
||||
CPU_ZERO(&cpuset);
|
||||
CPU_SET(affinity, &cpuset);
|
||||
AssertFatal( pthread_setaffinity_np(*t, sizeof(cpu_set_t), &cpuset) == 0, "Error setting processor affinity");
|
||||
}
|
||||
|
||||
pthread_attr_destroy(&attr);
|
||||
}
|
||||
|
||||
// Block CPU C-states deep sleep
|
||||
void configure_linux(void) {
|
||||
int ret;
|
||||
static int latency_target_fd=-1;
|
||||
uint32_t latency_target_value=10; // in microseconds
|
||||
if (latency_target_fd == -1) {
|
||||
if ( (latency_target_fd = open("/dev/cpu_dma_latency", O_RDWR)) != -1 ) {
|
||||
ret = write(latency_target_fd, &latency_target_value, sizeof(latency_target_value));
|
||||
if (ret == 0) {
|
||||
printf("# error setting cpu_dma_latency to %d!: %s\n", latency_target_value, strerror(errno));
|
||||
close(latency_target_fd);
|
||||
latency_target_fd=-1;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (latency_target_fd != -1)
|
||||
LOG_I(HW,"# /dev/cpu_dma_latency set to %dus\n", latency_target_value);
|
||||
else
|
||||
LOG_E(HW,"Can't set /dev/cpu_dma_latency to %dus\n", latency_target_value);
|
||||
|
||||
// Set CPU frequency to it's maximum
|
||||
if ( 0 != system("for d in /sys/devices/system/cpu/cpu[0-9]*; do cat $d/cpufreq/cpuinfo_max_freq > $d/cpufreq/scaling_min_freq; done"))
|
||||
LOG_W(HW,"Can't set cpu frequency\n");
|
||||
|
||||
}
|
||||
|
||||
@@ -21,6 +21,12 @@
|
||||
|
||||
#ifndef _SYSTEM_H_OAI_
|
||||
#define _SYSTEM_H_OAI_
|
||||
#include <stdint.h>
|
||||
#include <pthread.h>
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/****************************************************
|
||||
* send a command to the background process
|
||||
@@ -36,4 +42,23 @@ int background_system(char *command);
|
||||
|
||||
void start_background_system(void);
|
||||
|
||||
void set_latency_target(void);
|
||||
void configure_linux(void);
|
||||
|
||||
void threadCreate(pthread_t* t, void * (*func)(void*), void * param, char* name, int affinity, int priority);
|
||||
#define OAI_PRIORITY_RT_LOW sched_get_priority_min(SCHED_FIFO)
|
||||
#define OAI_PRIORITY_RT sched_get_priority_max(SCHED_FIFO)-10
|
||||
#define OAI_PRIORITY_RT_MAX sched_get_priority_max(SCHED_FIFO)
|
||||
|
||||
void thread_top_init(char *thread_name,
|
||||
int affinity,
|
||||
uint64_t runtime,
|
||||
uint64_t deadline,
|
||||
uint64_t period);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* _SYSTEM_H_OAI_ */
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
all: measurement_display thread-pool-test
|
||||
|
||||
measurement_display: measurement_display.c thread-pool.h
|
||||
gcc measurement_display.c -I /data/openairinterface5g.nr/common/utils/ -I. /data/openairinterface5g.nr/common/utils/backtrace.c -lpthread -D TEST_THREAD_POOL -I../LOG -I../../utils/T -o measurement_display
|
||||
gcc measurement_display.c -I ${OPENAIR_DIR}/ -I ${OPENAIR_DIR}/common/utils/ -I. ${OPENAIR_DIR}/common/utils/backtrace.c -lpthread -D TEST_THREAD_POOL -I../LOG -I../../utils/T -o measurement_display
|
||||
|
||||
thread-pool-test: thread-pool.c thread-pool.h
|
||||
gcc -g thread-pool.c -I /data/openairinterface5g.nr/common/utils/ -I. /data/openairinterface5g.nr/common/utils/backtrace.c -lpthread -D TEST_THREAD_POOL -I../LOG -I../../utils/T -o thread-pool-test
|
||||
gcc -g thread-pool.c -I ${OPENAIR_DIR}/ -I ${OPENAIR_DIR}/common/utils/ -I. ${OPENAIR_DIR}/common/utils/backtrace.c -I ${OPENAIR_DIR}/openair2/COMMON ${OPENAIR_DIR}/common/utils/LOG/log.c ${OPENAIR_DIR}/common/config/config_userapi.c ${OPENAIR_DIR}/common/config/config_load_configmodule.c ${OPENAIR_DIR}/common/config/config_cmdline.c -lpthread -ldl -D TEST_THREAD_POOL -I../LOG -I../../utils/T -o thread-pool-test
|
||||
|
||||
|
||||
@@ -2,22 +2,8 @@
|
||||
Author: Laurent THOMAS, Open Cells
|
||||
copyleft: OpenAirInterface Software Alliance and it's licence
|
||||
*/
|
||||
#include <common/utils/simple_executable.h>
|
||||
|
||||
#define __USE_GNU
|
||||
#define _GNU_SOURCE
|
||||
#include <stdio.h>
|
||||
#include <pthread.h>
|
||||
#include <sched.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <sys/time.h>
|
||||
#include <stdint.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include "thread-pool.h"
|
||||
|
||||
#define SEP "\t"
|
||||
@@ -26,7 +12,7 @@ uint64_t cpuCyclesMicroSec;
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
if(argc != 2) {
|
||||
printf("Need one paramter: the trace Linux pipe (fifo)");
|
||||
printf("Need one parameter: the trace Linux pipe (fifo)");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -49,23 +49,6 @@ void *one_thread(void *arg) {
|
||||
struct one_thread *myThread=(struct one_thread *) arg;
|
||||
struct thread_pool *tp=myThread->pool;
|
||||
|
||||
// configure the thread core assignment
|
||||
// TBD: reserve the core for us exclusively
|
||||
if ( myThread->coreID >= 0 && myThread->coreID < get_nprocs_conf()) {
|
||||
cpu_set_t cpuset;
|
||||
CPU_ZERO(&cpuset);
|
||||
CPU_SET(myThread->coreID, &cpuset);
|
||||
pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset);
|
||||
}
|
||||
|
||||
//Configure the thread scheduler policy for Linux
|
||||
struct sched_param sparam= {0};
|
||||
sparam.sched_priority = sched_get_priority_max(SCHED_RR);
|
||||
pthread_setschedparam(pthread_self(), SCHED_RR, &sparam);
|
||||
// set the thread name for debugging
|
||||
sprintf(myThread->name,"Tpool_%d",myThread->coreID);
|
||||
pthread_setname_np(pthread_self(), myThread->name );
|
||||
|
||||
// Infinite loop to process requests
|
||||
do {
|
||||
notifiedFIFO_elt_t *elt=pullNotifiedFifoRemember(&tp->incomingFifo, myThread);
|
||||
@@ -106,10 +89,6 @@ void initTpool(char *params,tpool_t *pool, bool performanceMeas) {
|
||||
} else
|
||||
pool->traceFd=-1;
|
||||
|
||||
//Configure the thread scheduler policy for Linux
|
||||
struct sched_param sparam= {0};
|
||||
sparam.sched_priority = sched_get_priority_max(SCHED_RR)-1;
|
||||
pthread_setschedparam(pthread_self(), SCHED_RR, &sparam);
|
||||
pool->activated=true;
|
||||
initNotifiedFIFO(&pool->incomingFifo);
|
||||
char *saveptr, * curptr;
|
||||
@@ -136,7 +115,11 @@ void initTpool(char *params,tpool_t *pool, bool performanceMeas) {
|
||||
pool->allthreads->coreID=atoi(curptr);
|
||||
pool->allthreads->id=pool->nbThreads;
|
||||
pool->allthreads->pool=pool;
|
||||
pthread_create(&pool->allthreads->threadID, NULL, one_thread, (void *)pool->allthreads);
|
||||
//Configure the thread scheduler policy for Linux
|
||||
// set the thread name for debugging
|
||||
sprintf(pool->allthreads->name,"Tpool_%d",pool->allthreads->coreID);
|
||||
threadCreate(&pool->allthreads->threadID, one_thread, (void *)pool->allthreads,
|
||||
pool->allthreads->name, pool->allthreads->coreID, OAI_PRIORITY_RT);
|
||||
pool->nbThreads++;
|
||||
}
|
||||
|
||||
@@ -151,6 +134,9 @@ void initTpool(char *params,tpool_t *pool, bool performanceMeas) {
|
||||
|
||||
#ifdef TEST_THREAD_POOL
|
||||
|
||||
void exit_function(const char *file, const char *function, const int line, const char *s) {
|
||||
}
|
||||
|
||||
struct testData {
|
||||
int id;
|
||||
char txt[30];
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include <sys/syscall.h>
|
||||
#include <assertions.h>
|
||||
#include <LOG/log.h>
|
||||
#include <common/utils/system.h>
|
||||
|
||||
#ifdef DEBUG
|
||||
#define THREADINIT PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP
|
||||
@@ -77,16 +78,18 @@ static inline void delNotifiedFIFO_elt(notifiedFIFO_elt_t *elt) {
|
||||
//LOG_W(UTIL,"delNotifiedFIFO on something not allocated by newNotifiedFIFO\n");
|
||||
}
|
||||
|
||||
static inline void initNotifiedFIFO_nothreadSafe(notifiedFIFO_t *nf) {
|
||||
nf->inF=NULL;
|
||||
nf->outF=NULL;
|
||||
}
|
||||
static inline void initNotifiedFIFO(notifiedFIFO_t *nf) {
|
||||
mutexinit(nf->lockF);
|
||||
condinit (nf->notifF);
|
||||
nf->inF=NULL;
|
||||
nf->outF=NULL;
|
||||
initNotifiedFIFO_nothreadSafe(nf);
|
||||
// No delete function: the creator has only to free the memory
|
||||
}
|
||||
|
||||
static inline void pushNotifiedFIFO(notifiedFIFO_t *nf, notifiedFIFO_elt_t *msg) {
|
||||
mutexlock(nf->lockF);
|
||||
static inline void pushNotifiedFIFO_nothreadSafe(notifiedFIFO_t *nf, notifiedFIFO_elt_t *msg) {
|
||||
msg->next=NULL;
|
||||
|
||||
if (nf->outF == NULL)
|
||||
@@ -96,22 +99,39 @@ static inline void pushNotifiedFIFO(notifiedFIFO_t *nf, notifiedFIFO_elt_t *msg)
|
||||
nf->inF->next = msg;
|
||||
|
||||
nf->inF = msg;
|
||||
}
|
||||
|
||||
static inline void pushNotifiedFIFO(notifiedFIFO_t *nf, notifiedFIFO_elt_t *msg) {
|
||||
mutexlock(nf->lockF);
|
||||
pushNotifiedFIFO_nothreadSafe(nf,msg);
|
||||
condbroadcast(nf->notifF);
|
||||
mutexunlock(nf->lockF);
|
||||
}
|
||||
|
||||
static inline notifiedFIFO_elt_t *pullNotifiedFIFO(notifiedFIFO_t *nf) {
|
||||
mutexlock(nf->lockF);
|
||||
|
||||
while(nf->outF == NULL)
|
||||
condwait(nf->notifF, nf->lockF);
|
||||
static inline notifiedFIFO_elt_t *pullNotifiedFIFO_nothreadSafe(notifiedFIFO_t *nf) {
|
||||
if (nf->outF == NULL)
|
||||
return NULL;
|
||||
|
||||
notifiedFIFO_elt_t *ret=nf->outF;
|
||||
|
||||
if (nf->outF==nf->outF->next)
|
||||
LOG_E(TMR,"Circular list in thread pool: push several times the same buffer is forbidden\n");
|
||||
|
||||
nf->outF=nf->outF->next;
|
||||
|
||||
if (nf->outF==NULL)
|
||||
nf->inF=NULL;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline notifiedFIFO_elt_t *pullNotifiedFIFO(notifiedFIFO_t *nf) {
|
||||
mutexlock(nf->lockF);
|
||||
notifiedFIFO_elt_t *ret;
|
||||
|
||||
while((ret=pullNotifiedFIFO_nothreadSafe(nf)) == NULL)
|
||||
condwait(nf->notifF, nf->lockF);
|
||||
|
||||
mutexunlock(nf->lockF);
|
||||
return ret;
|
||||
}
|
||||
@@ -122,18 +142,7 @@ static inline notifiedFIFO_elt_t *pollNotifiedFIFO(notifiedFIFO_t *nf) {
|
||||
if (tmp != 0 )
|
||||
return NULL;
|
||||
|
||||
notifiedFIFO_elt_t *ret=nf->outF;
|
||||
|
||||
if (ret!=NULL) {
|
||||
if (nf->outF==nf->outF->next)
|
||||
LOG_E(TMR,"Circular list in thread pool: push several times the same buffer is forbidden\n");
|
||||
|
||||
nf->outF=nf->outF->next;
|
||||
}
|
||||
|
||||
if (nf->outF==NULL)
|
||||
nf->inF=NULL;
|
||||
|
||||
notifiedFIFO_elt_t *ret=pullNotifiedFIFO_nothreadSafe(nf);
|
||||
mutexunlock(nf->lockF);
|
||||
return ret;
|
||||
}
|
||||
@@ -195,7 +204,7 @@ static inline notifiedFIFO_elt_t *pullTpool(notifiedFIFO_t *responseFifo, tpool_
|
||||
if (t->measurePerf)
|
||||
msg->returnTime=rdtsc();
|
||||
|
||||
if (t->traceFd)
|
||||
if (t->traceFd >= 0)
|
||||
if(write(t->traceFd, msg, sizeof(*msg)));
|
||||
|
||||
return msg;
|
||||
|
||||
Reference in New Issue
Block a user