Commit c1b8c6a9 authored by laurent's avatar laurent

new thread model - make affinity optional

parent 1f134370
...@@ -10,6 +10,8 @@ ...@@ -10,6 +10,8 @@
#include <fcntl.h> #include <fcntl.h>
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
#include <ctype.h>
#include <sys/sysinfo.h>
#include <threadPool/thread-pool.h> #include <threadPool/thread-pool.h>
void displayList(notifiedFIFO_t *nf) { void displayList(notifiedFIFO_t *nf) {
...@@ -46,12 +48,16 @@ static inline notifiedFIFO_elt_t *pullNotifiedFifoRemember( notifiedFIFO_t *nf, ...@@ -46,12 +48,16 @@ static inline notifiedFIFO_elt_t *pullNotifiedFifoRemember( notifiedFIFO_t *nf,
void *one_thread(void *arg) { void *one_thread(void *arg) {
struct one_thread *myThread=(struct one_thread *) arg; struct one_thread *myThread=(struct one_thread *) arg;
struct thread_pool *tp=myThread->pool; struct thread_pool *tp=myThread->pool;
// configure the thread core assignment // configure the thread core assignment
// TBD: reserve the core for us exclusively // TBD: reserve the core for us exclusively
if ( myThread->coreID >= 0 && myThread->coreID < get_nprocs_conf()) {
cpu_set_t cpuset; cpu_set_t cpuset;
CPU_ZERO(&cpuset); CPU_ZERO(&cpuset);
CPU_SET(myThread->coreID, &cpuset); CPU_SET(myThread->coreID, &cpuset);
pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset);
}
//Configure the thread scheduler policy for Linux //Configure the thread scheduler policy for Linux
struct sched_param sparam= {0}; struct sched_param sparam= {0};
sparam.sched_priority = sched_get_priority_max(SCHED_RR); sparam.sched_priority = sched_get_priority_max(SCHED_RR);
...@@ -112,22 +118,27 @@ void initTpool(char *params,tpool_t *pool, bool performanceMeas) { ...@@ -112,22 +118,27 @@ void initTpool(char *params,tpool_t *pool, bool performanceMeas) {
curptr=strtok_r(params,",",&saveptr); curptr=strtok_r(params,",",&saveptr);
while ( curptr!=NULL ) { while ( curptr!=NULL ) {
if (curptr[0] == 'u' || curptr[0] == 'U') { int c=toupper(curptr[0]);
switch (c) {
case 'U':
pool->restrictRNTI=true; pool->restrictRNTI=true;
} else if ( curptr[0]>='0' && curptr[0]<='9' ) { break;
struct one_thread *tmp=pool->allthreads;
case 'N':
pool->activated=false;
break;
default:
pool->allthreads=(struct one_thread *)malloc(sizeof(struct one_thread)); pool->allthreads=(struct one_thread *)malloc(sizeof(struct one_thread));
pool->allthreads->next=tmp; pool->allthreads->next=pool->allthreads;
printf("create a thread for core %d\n", atoi(curptr)); printf("create a thread for core %d\n", atoi(curptr));
pool->allthreads->coreID=atoi(curptr); pool->allthreads->coreID=atoi(curptr);
pool->allthreads->id=pool->nbThreads; pool->allthreads->id=pool->nbThreads;
pool->allthreads->pool=pool; pool->allthreads->pool=pool;
pthread_create(&pool->allthreads->threadID, NULL, one_thread, (void *)pool->allthreads); pthread_create(&pool->allthreads->threadID, NULL, one_thread, (void *)pool->allthreads);
pool->nbThreads++; pool->nbThreads++;
} else if (curptr[0] == 'n' || curptr[0] == 'N') { }
pool->activated=false;
} else
printf("Error in options for thread pool: %s\n",curptr);
curptr=strtok_r(NULL,",",&saveptr); curptr=strtok_r(NULL,",",&saveptr);
} }
......
...@@ -19,16 +19,6 @@ ...@@ -19,16 +19,6 @@
* contact@openairinterface.org * contact@openairinterface.org
*/ */
/*! \file lte-ue.c
* \brief threads and support functions for real-time LTE UE target
* \author R. Knopp, F. Kaltenberger, Navid Nikaein
* \date 2015
* \version 0.1
* \company Eurecom
* \email: knopp@eurecom.fr,florian.kaltenberger@eurecom.fr, navid.nikaein@eurecom.fr
* \note
* \warning
*/
#include "executables/nr-uesoftmodem.h" #include "executables/nr-uesoftmodem.h"
#include "LAYER2/NR_MAC_UE/mac.h" #include "LAYER2/NR_MAC_UE/mac.h"
...@@ -141,10 +131,6 @@ typedef enum { ...@@ -141,10 +131,6 @@ typedef enum {
si=2 si=2
} sync_mode_t; } sync_mode_t;
int32_t **rxdata;
int32_t **txdata;
#define KHz (1000UL) #define KHz (1000UL)
#define MHz (1000*KHz) #define MHz (1000*KHz)
typedef struct eutra_band_s { typedef struct eutra_band_s {
......
...@@ -709,7 +709,7 @@ int main( int argc, char **argv ) { ...@@ -709,7 +709,7 @@ int main( int argc, char **argv ) {
set_taus_seed (0); set_taus_seed (0);
tpool_t pool; tpool_t pool;
Tpool = &pool; Tpool = &pool;
char params[]="1,2,3,u"; char params[]="-1,-1,-1,-1";
initTpool(params, Tpool, false); initTpool(params, Tpool, false);
cpuf=get_cpu_freq_GHz(); cpuf=get_cpu_freq_GHz();
itti_init(TASK_MAX, THREAD_MAX, MESSAGES_ID_MAX, tasks_info, messages_info); itti_init(TASK_MAX, THREAD_MAX, MESSAGES_ID_MAX, tasks_info, messages_info);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment