RTAI on a debian distro - Unsure why this C thread code (implements a simple counter) would cause linux to crash -
The
I have a log file via printk This is the code that implements a simple counter and zero thread_code (function to write this void * is applied by args), and then it __init rtcode_init (zero) in the thread real time. This question is an examination question.
I'm sure why the code will cause Linux to crash. Is it due to steady work, because it can cause a race condition if you can reach the function arriving memory address multiple threads? It would be better to have someone say what is wrong with the code.
#define ARG 0 #define STACK_SIZE 1024 #define preference RT_SCHED_HIGHEST_PRIORITY #define USE_FPU 1 #define now rt_get_time () #define period nano2count (1000000) / * store data for thread * / RT_TASK Required thread_data; Zero Threadcode (Zero * arg) {int counter = 0; While (1) {counter + = 1; Printer ("counter =% d \ n", counter); } Return 0; } Fixed integer __init rtcode_init (zero) {rt_set_periodic_mode (); Start_rt_timer (period); rt_task_init (& amp; thread_data, thread_code, ARG, STACK_SIZE, priority, USE_FPU, null); Rt_task_make_periodic (& thread_data, now, duration); Return 0; }
This is the code that runs continuously creates a work with real-time priority. If your system has only one CPU core, then it will not be able to stop anything from running, which will make the system unusable. I do not think it will be "crash", ok, but it will stop answering the input.
Comments
Post a Comment