All of lore.kernel.org
 help / color / mirror / Atom feed
* [Xenomai-help] rt_mutex created prior to main causes board to freeze?
@ 2010-05-14 16:00 Sherk Chung
  2010-05-14 16:42 ` Gilles Chanteperdrix
  2010-05-16 15:43 ` Gilles Chanteperdrix
  0 siblings, 2 replies; 8+ messages in thread
From: Sherk Chung @ 2010-05-14 16:00 UTC (permalink / raw)
  To: xenomai

[-- Attachment #1: Type: text/plain, Size: 2578 bytes --]

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);

 

}


[-- Attachment #2: Type: text/html, Size: 9175 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2010-05-16 15:43 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-14 16:00 [Xenomai-help] rt_mutex created prior to main causes board to freeze? Sherk Chung
2010-05-14 16:42 ` Gilles Chanteperdrix
2010-05-14 16:44   ` Gilles Chanteperdrix
2010-05-14 19:40   ` Travis Stratman
2010-05-14 21:53     ` Gilles Chanteperdrix
2010-05-14 22:17       ` Travis Stratman
2010-05-14 23:37         ` Travis Stratman
2010-05-16 15:43 ` Gilles Chanteperdrix

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.