All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
To: Sherk Chung <sherk.chung@domain.hid>
Cc: xenomai@xenomai.org
Subject: Re: [Xenomai-help] rt_mutex created prior to main causes board to freeze?
Date: Sun, 16 May 2010 17:43:13 +0200	[thread overview]
Message-ID: <4BF01291.7060008@domain.hid> (raw)
In-Reply-To: <2319761F7FA0D1479BA77EC2E0A8E7BCE3D72A@alpine.pivotalsys.com>

Sherk Chung wrote:
> 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)

Hi,

your test program does not compile, next time, please provide a 
self-contained test which I only have to compile in order to be able to 
run it. I compiled and ran the following program:

#include <native/queue.h>
#include <native/mutex.h>
#include <signal.h>
#include <sys/mman.h>


template <class T>
class SyncObject {
private:
        RT_MUTEX mutex;

public:
        T value;

        SyncObject(const char* desc)
        {
                printf("mutex_create !\n");
                rt_mutex_create(&mutex, desc);
        }

        ~SyncObject()
        {
                rt_mutex_delete(&mutex);
        }

        void lock()

        void unlock()
        {
                rt_mutex_release(&mutex);
        }
} ;

SyncObject<int> g_sharedVar1 = "var1";
SyncObject<int> g_sharedVar2 = "var2";
SyncObject<int> g_sharedVar3 = "var3";

extern "C" int main(void)
{
        printf ("Starting execution of main");   //  Program crashes before

        mlockall(MCL_CURRENT | MCL_FUTURE);
	return 0;
}

And it runs just fine. So, I need more details, such as your kernel
configuration.

-- 
					    Gilles.


      parent reply	other threads:[~2010-05-16 15:43 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4BF01291.7060008@domain.hid \
    --to=gilles.chanteperdrix@xenomai.org \
    --cc=sherk.chung@domain.hid \
    --cc=xenomai@xenomai.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.