We are using Xenomai on an AT91 ARM board. We wrote a program that
creates multiple Xenomai tasks, which use rt_mutexes to when accessing
some shared global variables. The rt_mutexes used are declared
globally, as in the example below. Since the objects sharedVar1,
shredVar2, etc. are declared on the global stack, the rt_mutexes are
created prior to main() getting executed. The problem we are having is
that our program is causing our HW to freeze up on program load, it
never gets to the first line of main(), and our HW supplier pointed out
that we must call mlockall() and the set up the signal handlers before
creating the mutexes.
Is there a problem with creating rt_mutexes the way we are doing, and
should that cause the ARM board to freeze? (the same program loads fine
on an x86)
Thanks in advance.
-Sherk
-------------
#include <native/queue.h>
#include <native/mutex.h>
#include "main.h"
template <class T>
class SyncObject {
private:
RT_MUTEX mutex;
public:
T value;
SyncObject(const char* desc){ rt_mutex_create(&mutex, desc); }
~SyncObject(){ rt_mutex_delete(&mutex); }
void lock(){ rt_mutex_acquire(&mutex, TM_INFINITE); }
void unlock(){ rt_mutex_release(&mutex); }
} ;
SyncObject<int> g_sharedVar1; // global sync object used by multiple
tasks
SyncObject<int> g_sharedVar2; // global sync object used by multiple
tasks
SyncObject<int> g_sharedVar3; // global sync object used by multiple
tasks
main(argv, argc)
{
printf ("Starting execution of main"); // Program crashes before
executing this line of code
signal(SIGTERM, handleShutdownSignal);
signal(SIGINT, handleShutdownSignal);
signal(SIGXCPU, handleTaskModeChange); // signal num 24
mlockall(MCL_CURRENT | MCL_FUTURE);
// create all queues
err = rt_queue_create(&g_output_data_queue, g_output_data_queue_name,
OUTPUT_DATA_Q_LEN * sizeof(OutputData), OUTPUT_DATA_Q_LEN, Q_SHARED);
err = rt_queue_create(&g_log_queue, g_log_queue_name, LOG_Q_LEN *
sizeof(LogMessage), LOG_Q_LEN, Q_SHARED);
// create all remaining tasks ///////
err = rt_task_spawn(&rtTask1,"Task1", 0, 2, 0, &task1, &errHandler1);
err = rt_task_spawn(&rtTask2," Task2", 0, 10, 0, &task2,
&errHandler2);
err = rt_task_spawn(&rtTask3,"Task3", 0, 10, 0, &task3, &errHandler3);
err = rt_task_spawn(&rtTask4,"Task4", 0, 2, 0, &task4, & errHandler4);
}
_______________________________________________
Xenomai-help mailing list
[email protected]
https://mail.gna.org/listinfo/xenomai-help