Commit 19558fda authored by Florian Kaltenberger's avatar Florian Kaltenberger
Browse files

Merge branch 'test-x310' into 'develop-nr'

Test x310

See merge request oai/openairinterface5g!585
parents ee99817d 290ca22d
...@@ -754,6 +754,7 @@ include_directories("${OPENAIR_BIN_DIR}") ...@@ -754,6 +754,7 @@ include_directories("${OPENAIR_BIN_DIR}")
# Legacy exact order # Legacy exact order
include_directories("${OPENAIR_DIR}/executables")
include_directories("${OPENAIR2_DIR}/COMMON") include_directories("${OPENAIR2_DIR}/COMMON")
include_directories("${OPENAIR2_DIR}/UTIL") include_directories("${OPENAIR2_DIR}/UTIL")
include_directories("${OPENAIR2_DIR}/UTIL/LOG") include_directories("${OPENAIR2_DIR}/UTIL/LOG")
...@@ -2113,11 +2114,18 @@ if (${XFORMS}) ...@@ -2113,11 +2114,18 @@ if (${XFORMS})
${OPENAIR1_DIR}/PHY/TOOLS/nr_phy_scope.c ${OPENAIR1_DIR}/PHY/TOOLS/nr_phy_scope.c
) )
set(XFORMS_SOURCE_SOFTMODEM set(XFORMS_SOURCE_SOFTMODEM
${OPENAIR_TARGETS}/RT/USER/stats.c ${OPENAIR_DIR}/targets/RT/USER/stats.c
) )
set(XFORMS_LIBRARIES "forms") set(XFORMS_LIBRARIES "forms")
endif (${XFORMS}) endif (${XFORMS})
include_directories ("/usr/include/X11")
add_library(gnbScope MODULE
${OPENAIR1_DIR}/PHY/TOOLS/nr_phy_scope.c
)
target_link_libraries(gnbScope forms)
set(CMAKE_MODULE_PATH "${OPENAIR_DIR}/cmake_targets/tools/MODULES" "${CMAKE_MODULE_PATH}") set(CMAKE_MODULE_PATH "${OPENAIR_DIR}/cmake_targets/tools/MODULES" "${CMAKE_MODULE_PATH}")
#include T directory even if the T is off because T macros are in the code #include T directory even if the T is off because T macros are in the code
...@@ -2161,6 +2169,24 @@ add_definitions(-DASN1_MINIMUM_VERSION=924) ...@@ -2161,6 +2169,24 @@ add_definitions(-DASN1_MINIMUM_VERSION=924)
################################# #################################
# add executables for operation # add executables for operation
################################# #################################
add_library(minimal_lib
${OPENAIR_DIR}/common/utils/backtrace.c
${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
${OPENAIR_DIR}/common/utils/minimal_stub.c
)
target_link_libraries(minimal_lib pthread dl)
add_executable(replay_node
${OPENAIR_TARGETS}/ARCH/rfsimulator/stored_node.c
)
target_link_libraries (replay_node minimal_lib)
add_executable(measurement_display
${OPENAIR_DIR}/common/utils/threadPool/measurement_display.c)
target_link_libraries (measurement_display minimal_lib)
# lte-softmodem is both eNB and UE implementation # lte-softmodem is both eNB and UE implementation
################################################### ###################################################
...@@ -2323,19 +2349,16 @@ add_executable(nr-softmodem ...@@ -2323,19 +2349,16 @@ add_executable(nr-softmodem
${nr_rrc_h} ${nr_rrc_h}
${s1ap_h} ${s1ap_h}
# ${OPENAIR_BIN_DIR}/messages_xml.h # ${OPENAIR_BIN_DIR}/messages_xml.h
${OPENAIR_TARGETS}/RT/USER/rt_wrapper.c ${OPENAIR_DIR}/executables/nr-gnb.c
${OPENAIR_TARGETS}/RT/USER/nr-gnb.c ${OPENAIR_DIR}/executables/nr-ru.c
${OPENAIR_TARGETS}/RT/USER/nr-ru.c ${OPENAIR_DIR}/executables/nr-softmodem.c
${OPENAIR_TARGETS}/RT/USER/nr-softmodem.c
${OPENAIR1_DIR}/SIMULATION/TOOLS/taus.c ${OPENAIR1_DIR}/SIMULATION/TOOLS/taus.c
${OPENAIR_TARGETS}/COMMON/create_nr_tasks.c
${OPENAIR_TARGETS}/ARCH/COMMON/common_lib.c ${OPENAIR_TARGETS}/ARCH/COMMON/common_lib.c
${OPENAIR1_DIR}/SIMULATION/ETH_TRANSPORT/netlink_init.c ${OPENAIR1_DIR}/SIMULATION/ETH_TRANSPORT/netlink_init.c
${OPENAIR_DIR}/common/utils/utils.c ${OPENAIR_DIR}/common/utils/utils.c
${OPENAIR_DIR}/common/utils/system.c ${OPENAIR_DIR}/common/utils/system.c
${GTPU_need_ITTI} ${GTPU_need_ITTI}
${XFORMS_SOURCE} ${XFORMS_SOURCE_NR}
${XFORMS_SOURCE_SOFTMODEM}
${T_SOURCE} ${T_SOURCE}
${CONFIG_SOURCES} ${CONFIG_SOURCES}
${SHLIB_LOADER_SOURCES} ${SHLIB_LOADER_SOURCES}
...@@ -2361,13 +2384,10 @@ add_executable(nr-softmodem-nos1 ...@@ -2361,13 +2384,10 @@ add_executable(nr-softmodem-nos1
${rrc_h} ${rrc_h}
${s1ap_h} ${s1ap_h}
# ${OPENAIR_BIN_DIR}/messages_xml.h # ${OPENAIR_BIN_DIR}/messages_xml.h
${OPENAIR_TARGETS}/RT/USER/rt_wrapper.c ${OPENAIR_DIR}/executables/nr-gnb.c
${OPENAIR_TARGETS}/RT/USER/nr-gnb.c ${OPENAIR_DIR}/executables/nr-ru.c
${OPENAIR_TARGETS}/RT/USER/nr-ru.c ${OPENAIR_DIR}/executables/nr-softmodem.c
${OPENAIR_TARGETS}/RT/USER/nr-softmodem.c
${OPENAIR1_DIR}/SIMULATION/TOOLS/taus.c ${OPENAIR1_DIR}/SIMULATION/TOOLS/taus.c
${OPENAIR_TARGETS}/COMMON/create_tasks.c
${OPENAIR_TARGETS}/COMMON/create_nr_tasks.c
${OPENAIR_TARGETS}/ARCH/COMMON/common_lib.c ${OPENAIR_TARGETS}/ARCH/COMMON/common_lib.c
${OPENAIR2_DIR}/RRC/NAS/nas_config.c ${OPENAIR2_DIR}/RRC/NAS/nas_config.c
${OPENAIR2_DIR}/RRC/NAS/rb_config.c ${OPENAIR2_DIR}/RRC/NAS/rb_config.c
...@@ -2375,8 +2395,7 @@ add_executable(nr-softmodem-nos1 ...@@ -2375,8 +2395,7 @@ add_executable(nr-softmodem-nos1
${OPENAIR_DIR}/common/utils/utils.c ${OPENAIR_DIR}/common/utils/utils.c
${OPENAIR_DIR}/common/utils/system.c ${OPENAIR_DIR}/common/utils/system.c
${GTPU_need_ITTI} ${GTPU_need_ITTI}
${XFORMS_SOURCE} ${XFORMS_SOURCE_NR}
${XFORMS_SOURCE_SOFTMODEM}
${T_SOURCE} ${T_SOURCE}
${CONFIG_SOURCES} ${CONFIG_SOURCES}
${SHLIB_LOADER_SOURCES} ${SHLIB_LOADER_SOURCES}
...@@ -2412,7 +2431,6 @@ add_executable(nr-uesoftmodem ...@@ -2412,7 +2431,6 @@ add_executable(nr-uesoftmodem
${OPENAIR_DIR}/common/utils/utils.c ${OPENAIR_DIR}/common/utils/utils.c
${OPENAIR_DIR}/common/utils/system.c ${OPENAIR_DIR}/common/utils/system.c
${XFORMS_SOURCE_NR} ${XFORMS_SOURCE_NR}
${XFORMS_SOURCE_SOFTMODEM}
${T_SOURCE} ${T_SOURCE}
${CONFIG_SOURCES} ${CONFIG_SOURCES}
${SHLIB_LOADER_SOURCES} ${SHLIB_LOADER_SOURCES}
...@@ -2436,17 +2454,14 @@ add_executable(nr-uesoftmodem-nos1 ...@@ -2436,17 +2454,14 @@ add_executable(nr-uesoftmodem-nos1
${rrc_h} ${rrc_h}
${s1ap_h} ${s1ap_h}
# ${OPENAIR_BIN_DIR}/messages_xml.h # ${OPENAIR_BIN_DIR}/messages_xml.h
${OPENAIR_TARGETS}/RT/USER/rt_wrapper.c
${OPENAIR_DIR}/executables/nr-ue.c ${OPENAIR_DIR}/executables/nr-ue.c
${OPENAIR_DIR}/executables/nr-uesoftmodem.c ${OPENAIR_DIR}/executables/nr-uesoftmodem.c
${OPENAIR1_DIR}/SIMULATION/TOOLS/taus.c ${OPENAIR1_DIR}/SIMULATION/TOOLS/taus.c
#${OPENAIR_TARGETS}/COMMON/create_tasks_ue.c
${OPENAIR_TARGETS}/ARCH/COMMON/common_lib.c ${OPENAIR_TARGETS}/ARCH/COMMON/common_lib.c
${OPENAIR1_DIR}/SIMULATION/ETH_TRANSPORT/netlink_init.c ${OPENAIR1_DIR}/SIMULATION/ETH_TRANSPORT/netlink_init.c
${OPENAIR_DIR}/common/utils/utils.c ${OPENAIR_DIR}/common/utils/utils.c
${OPENAIR_DIR}/common/utils/system.c ${OPENAIR_DIR}/common/utils/system.c
${XFORMS_SOURCE_NR} ${XFORMS_SOURCE_NR}
${XFORMS_SOURCE_SOFTMODEM}
${T_SOURCE} ${T_SOURCE}
${CONFIG_SOURCES} ${CONFIG_SOURCES}
${SHLIB_LOADER_SOURCES} ${SHLIB_LOADER_SOURCES}
...@@ -2498,6 +2513,7 @@ target_link_libraries (nr-uesoftmodem-nos1 ${T_LIB}) ...@@ -2498,6 +2513,7 @@ target_link_libraries (nr-uesoftmodem-nos1 ${T_LIB})
add_executable(dlsim_tm4 add_executable(dlsim_tm4
${OPENAIR1_DIR}/SIMULATION/LTE_PHY/dlsim_tm4.c ${OPENAIR1_DIR}/SIMULATION/LTE_PHY/dlsim_tm4.c
${OPENAIR1_DIR}/PHY/TOOLS/lte_phy_scope_tm4.c ${OPENAIR1_DIR}/PHY/TOOLS/lte_phy_scope_tm4.c
${OPENAIR_DIR}/common/utils/system.c
${T_SOURCE} ${T_SOURCE}
) )
target_link_libraries (dlsim_tm4 target_link_libraries (dlsim_tm4
...@@ -2524,18 +2540,21 @@ target_link_libraries(ldpctest SIMU PHY PHY_NR m ${ATLAS_LIBRARIES}) ...@@ -2524,18 +2540,21 @@ target_link_libraries(ldpctest SIMU PHY PHY_NR m ${ATLAS_LIBRARIES})
add_executable(nr_dlschsim add_executable(nr_dlschsim
${OPENAIR1_DIR}/SIMULATION/NR_PHY/dlschsim.c ${OPENAIR1_DIR}/SIMULATION/NR_PHY/dlschsim.c
${OPENAIR_DIR}/common/utils/backtrace.c ${OPENAIR_DIR}/common/utils/backtrace.c
${OPENAIR_DIR}/common/utils/system.c
${T_SOURCE}) ${T_SOURCE})
target_link_libraries(nr_dlschsim -Wl,--start-group UTIL SIMU PHY_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB CONFIG_LIB -Wl,--end-group m pthread ${ATLAS_LIBRARIES} ${T_LIB} dl) target_link_libraries(nr_dlschsim -Wl,--start-group UTIL SIMU PHY_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB CONFIG_LIB -Wl,--end-group m pthread ${ATLAS_LIBRARIES} ${T_LIB} dl)
add_executable(nr_pbchsim add_executable(nr_pbchsim
${OPENAIR1_DIR}/SIMULATION/NR_PHY/pbchsim.c ${OPENAIR1_DIR}/SIMULATION/NR_PHY/pbchsim.c
${OPENAIR_DIR}/common/utils/backtrace.c ${OPENAIR_DIR}/common/utils/backtrace.c
${OPENAIR_DIR}/common/utils/system.c
${T_SOURCE}) ${T_SOURCE})
target_link_libraries(nr_pbchsim -Wl,--start-group UTIL SIMU PHY_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB CONFIG_LIB -Wl,--end-group m pthread ${ATLAS_LIBRARIES} ${T_LIB} dl) target_link_libraries(nr_pbchsim -Wl,--start-group UTIL SIMU PHY_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB CONFIG_LIB -Wl,--end-group m pthread ${ATLAS_LIBRARIES} ${T_LIB} dl)
add_executable(nr_dlsim add_executable(nr_dlsim
${OPENAIR1_DIR}/SIMULATION/NR_PHY/dlsim.c ${OPENAIR1_DIR}/SIMULATION/NR_PHY/dlsim.c
${OPENAIR_DIR}/common/utils/backtrace.c ${OPENAIR_DIR}/common/utils/backtrace.c
${OPENAIR_DIR}/common/utils/system.c
${T_SOURCE}) ${T_SOURCE})
target_link_libraries(nr_dlsim -Wl,--start-group UTIL SIMU PHY_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB SCHED_NR_UE_LIB MAC_NR MAC_UE_NR MAC_NR_COMMON RRC_LIB NR_RRC_LIB CONFIG_LIB L2_NR -Wl,--end-group m pthread ${ATLAS_LIBRARIES} ${T_LIB} dl) target_link_libraries(nr_dlsim -Wl,--start-group UTIL SIMU PHY_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB SCHED_NR_UE_LIB MAC_NR MAC_UE_NR MAC_NR_COMMON RRC_LIB NR_RRC_LIB CONFIG_LIB L2_NR -Wl,--end-group m pthread ${ATLAS_LIBRARIES} ${T_LIB} dl)
...@@ -2551,6 +2570,7 @@ foreach(myExe dlsim dlsim_tm7 ulsim pbchsim scansim mbmssim pdcchsim pucchsim pr ...@@ -2551,6 +2570,7 @@ foreach(myExe dlsim dlsim_tm7 ulsim pbchsim scansim mbmssim pdcchsim pucchsim pr
add_executable(${myExe} add_executable(${myExe}
${OPENAIR1_DIR}/SIMULATION/LTE_PHY/${myExe}.c ${OPENAIR1_DIR}/SIMULATION/LTE_PHY/${myExe}.c
${OPENAIR_DIR}/common/utils/backtrace.c ${OPENAIR_DIR}/common/utils/backtrace.c
${OPENAIR_DIR}/common/utils/system.c
${XFORMS_SOURCE} ${XFORMS_SOURCE}
${T_SOURCE} ${T_SOURCE}
${CONFIG_SOURCES} ${CONFIG_SOURCES}
......
...@@ -420,11 +420,6 @@ function main() { ...@@ -420,11 +420,6 @@ function main() {
CMAKE_CMD="$CMAKE_CMD .." CMAKE_CMD="$CMAKE_CMD .."
echo_info "CMAKE_CMD=$CMAKE_CMD" echo_info "CMAKE_CMD=$CMAKE_CMD"
if [ "$eNB" = "1" -o "$gNB" = "1" ] && [ "$UE" = "1" -o "$nrUE" = "1" ]; then
echo_error "Cannot build UE/nrUE and eNB/gNB on one build_oai execution"
echo_error "use 2 build_oai invocations"
exit
fi
######################################################### #########################################################
# check validity of HW and TP parameters for eNB / gNB # check validity of HW and TP parameters for eNB / gNB
......
int T_stdout;
void exit_function(const char *file, const char *function, const int line, const char *s) {
}
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <intertask_interface.h> #include <intertask_interface.h>
#include <common/utils/system.h>
typedef struct timer_elm_s { typedef struct timer_elm_s {
timer_type_t type; ///< Timer type timer_type_t type; ///< Timer type
...@@ -280,22 +281,8 @@ extern "C" { ...@@ -280,22 +281,8 @@ extern "C" {
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]; task_list_t *t=&tasks[task_id];
AssertFatal ( pthread_create (&t->thread, NULL, start_routine, args_p) ==0, threadCreate (&t->thread, start_routine, args_p, (char*)itti_get_task_name(task_id),-1,OAI_PRIORITY_RT);
"Thread creation for task %d failed!\n", task_id);
pthread_setname_np( t->thread, itti_get_task_name(task_id) );
LOG_I(TMR,"Created Posix thread %s\n", itti_get_task_name(task_id) ); 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; return 0;
} }
......
#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
...@@ -28,13 +28,23 @@ ...@@ -28,13 +28,23 @@
* separate process solves this problem. * separate process solves this problem.
*/ */
#define _GNU_SOURCE
#include "system.h" #include "system.h"
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include <pthread.h> #include <pthread.h>
#include <string.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 #define MAX_COMMAND 4096
static int command_pipe_read; static int command_pipe_read;
...@@ -50,37 +60,37 @@ static int module_initialized = 0; ...@@ -50,37 +60,37 @@ static int module_initialized = 0;
/* util functions */ /* util functions */
/********************************************************************/ /********************************************************************/
static void lock_system(void) static void lock_system(void) {
{
if (pthread_mutex_lock(&lock) != 0) { if (pthread_mutex_lock(&lock) != 0) {
printf("pthread_mutex_lock fails\n"); printf("pthread_mutex_lock fails\n");
abort(); abort();
} }
} }
static void unlock_system(void) static void unlock_system(void) {
{
if (pthread_mutex_unlock(&lock) != 0) { if (pthread_mutex_unlock(&lock) != 0) {
printf("pthread_mutex_unlock fails\n"); printf("pthread_mutex_unlock fails\n");
abort(); abort();
} }
} }
static void write_pipe(int p, char *b, int size) static void write_pipe(int p, char *b, int size) {
{
while (size) { while (size) {
int ret = write(p, b, size); int ret = write(p, b, size);
if (ret <= 0) exit(0); if (ret <= 0) exit(0);
b += ret; b += ret;
size -= 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) { while (size) {
int ret = read(p, b, size); int ret = read(p, b, size);
if (ret <= 0) exit(0); if (ret <= 0) exit(0);
b += ret; b += ret;
size -= ret; size -= ret;
} }
...@@ -95,14 +105,13 @@ static void read_pipe(int p, char *b, int size) ...@@ -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 * when the main process exits, because then a "read" on the pipe
* will return 0, in which case "read_pipe" exits. * will return 0, in which case "read_pipe" exits.
*/ */
static void background_system_process(void) static void background_system_process(void) {
{
int len; int len;
int ret; int ret;
char command[MAX_COMMAND+1]; char command[MAX_COMMAND+1];
while (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); read_pipe(command_pipe_read, command, len);
ret = system(command); ret = system(command);
write_pipe(result_pipe_write, (char *)&ret, sizeof(int)); write_pipe(result_pipe_write, (char *)&ret, sizeof(int));
...@@ -114,8 +123,7 @@ static void background_system_process(void) ...@@ -114,8 +123,7 @@ static void background_system_process(void)
/* return -1 on error, 0 on success */ /* return -1 on error, 0 on success */
/********************************************************************/ /********************************************************************/
int background_system(char *command) int background_system(char *command) {
{
int res; int res;
int len; int len;
...@@ -125,18 +133,22 @@ int background_system(char *command) ...@@ -125,18 +133,22 @@ int background_system(char *command)
} }
len = strlen(command)+1; len = strlen(command)+1;
if (len > MAX_COMMAND) { if (len > MAX_COMMAND) {
printf("FATAL: command too long. Increase MAX_COMMAND (%d).\n", MAX_COMMAND); printf("FATAL: command too long. Increase MAX_COMMAND (%d).\n", MAX_COMMAND);
printf("command was: '%s'\n", command); printf("command was: '%s'\n", command);
abort(); abort();
} }
/* only one command can run at a time, so let's lock/unlock */ /* only one command can run at a time, so let's lock/unlock */
lock_system(); 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); 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(); unlock_system();
if (res == -1 || !WIFEXITED(res) || WEXITSTATUS(res) != 0) return -1; if (res == -1 || !WIFEXITED(res) || WEXITSTATUS(res) != 0) return -1;
return 0; return 0;
} }
...@@ -146,17 +158,16 @@ int background_system(char *command) ...@@ -146,17 +158,16 @@ int background_system(char *command)
/* to be called very early by the main processing */ /* to be called very early by the main processing */
/********************************************************************/ /********************************************************************/
void start_background_system(void) void start_background_system(void) {
{
int p[2]; int p[2];
pid_t son; pid_t son;
module_initialized = 1; module_initialized = 1;
if (pipe(p) == -1) { if (pipe(p) == -1) {
perror("pipe"); perror("pipe");
exit(1); exit(1);
} }
command_pipe_read = p[0]; command_pipe_read = p[0];
command_pipe_write = p[1]; command_pipe_write = p[1];
...@@ -164,10 +175,11 @@ void start_background_system(void) ...@@ -164,10 +175,11 @@ void start_background_system(void)
perror("pipe"); perror("pipe");
exit(1); exit(1);
} }
result_pipe_read = p[0]; result_pipe_read = p[0];
result_pipe_write = p[1]; result_pipe_write = p[1];
son = fork(); son = fork();
if (son == -1) { if (son == -1) {
perror("fork"); perror("fork");
exit(1); exit(1);
...@@ -181,6 +193,56 @@ void start_background_system(void) ...@@ -181,6 +193,56 @@ void start_background_system(void)
close(result_pipe_read); close(result_pipe_read);
close(command_pipe_write); close(command_pipe_write);
background_system_process(); 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