Skip to contentSkip to conversation

process memory not locked

Xenomai-help Saiful Khan 3 participants 7 messages Mar 6, 2007 – Mar 11, 2007 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

Hello,

I have ported my normal GNU/Linux (Posix) application in Xenomai, and I have used Xenomai POSIX skin to do the same. In my application main() function is spawning a thread using
pthread_attr_init()
pthread_attr_setdetachstate()
pthread_create()

But as soon as it spawn the thread the following message comes *Xenomai*: process *memory not locked* (missing mlockall?), and I do not get any message from that thread.

I have already locked the paging in main() as well as in the spawned thread using mlockall(MCL_CURRENT | MCL_FUTURE). After google search I didnt found any solution to solve my problem.

1. Please tell me the reason? Is there anything I am doing wrong while spawning thread?
2. What to do so that the thread also run in highest priority?

Thanks and regards
Saiful

#1 lore raw
Quoted 13 lines · Saiful Khan

Hello,

I have ported my normal GNU/Linux (Posix) application in Xenomai, and I have used Xenomai POSIX skin to do the same. In my application main() function is spawning a thread using
pthread_attr_init()
pthread_attr_setdetachstate()
pthread_create()

But as soon as it spawn the thread the following message comes *Xenomai*: process *memory not locked* (missing mlockall?), and I do not get any message from that thread.

Quoted 6 lines

I have already locked the paging in main() as well as in the spawned thread using mlockall(MCL_CURRENT | MCL_FUTURE). After google search I didnt found any solution to solve my problem.

1. Please tell me the reason? Is there anything I am doing wrong while spawning thread?

Are you sure mlockall suceeded ? Check its return value to know.

Quoted 1 line

2. What to do so that the thread also run in highest priority?

Use pthread_attr_setschedparam, or pthread_setschedparam.

Signature · 1 line
                                                 Gilles Chanteperdrix
#3 lore raw

Hello,

First of all thank you a lot. For the last several days I am getting lots of help from you. As well as I achived some positive results also. By the way my observation now is -

mlockall is successfull
pthread_attr_init() - is successfull pthread_attr_setdetachstate() - successfull
Here I am getting the message "Xenomai - process memory not locked (missing mlockall?)" and its stuck.
pthread_create() - this is returning nothing not success(0) nor failure.

What can be the possible reason?

Thanks and regards
Saiful

Quoted 16 lines · Gilles Chanteperdrix
Quoted 5 lines · Gilles Chanteperdrix
Quoted 1 line

2. What to do so that the thread also run in highest priority?

Use pthread_attr_setschedparam, or pthread_setschedparam.

Start here and follow the links:

http://www.xenomai.org/documentation/branches/v2.3.x/html/api/group__posix__sched.html

--
Gilles Chanteperdrix

#4 lore raw
Quoted 6 lines · Saiful Khan

Hello,

First of all thank you a lot. For the last several days I am getting lots of help from you. As well as I achived some positive results also. By the way my observation now is -

Quoted 8 lines

mlockall is successfull
pthread_attr_init() - is successfull pthread_attr_setdetachstate() - successfull
Here I am getting the message "Xenomai - process memory not locked (missing mlockall?)" and its stuck.
pthread_create() - this is returning nothing not success(0) nor failure.

What can be the possible reason?

Maybe a bug, could you tell us what version of the Adeos patch and of Xenomai you are using, and send a short program that exhibits this behaviour ?

Signature · 1 line
					    Gilles Chanteperdrix.

A message that is not in the archive (sent off-list or not yet received): [email protected]

#6 lore raw
Quoted 9 lines · Saiful Khan

Sorry for late reply. Actualy what I saw that in that application one fork() is there, so basically child process is trying to create the thread and fails. I removed the fork() and spawned the thread from the main and succeed. But the application is so large that, if i remove the fork() then I need to change the entire architecture of the application, another big task... Can u please tell me what is the alternative of fork()?

Thanks and regards
Saiful

To quote mlockall manual page: "Memory locks are not inherited by a child created via fork(2) and are automatically removed (unlocked) during an execve(2) or when the process terminates."

So, a forked child has to call mlockall to lock its memory.

Beware, however, that calling fork in a real-time application raises some issues which have been solved recently: only trunk and latest branch v2.3.x contain the fixes needed to safely call fork in a real-time application.

Signature · 1 line
					    Gilles Chanteperdrix.
#7 lore raw
In reply to Saiful Khan
Quoted 11 lines · Saiful Khan

Hello,

First of all thank you a lot. For the last several days I am getting lots of help from you. As well as I achived some positive results also. By the way my observation now is -

mlockall is successfull
pthread_attr_init() - is successfull
pthread_attr_setdetachstate() - successfull
Here I am getting the message "Xenomai - process memory not locked (missing mlockall?) " and its stuck.

Do I understand ("stuck") right that the following pthread_create() is never executed?

Quoted 1 line

pthread_create() - this is returning nothing not success(0) nor failure.

Could you insert additional debugging lines in your code as shown below and let us know of the outcome?

// btw does "attr" in your case allocated on stack?

pthread_attr_init(&attr);
printf("step 1\n");

memset(&attr, 0, sizeof(pthread_attr_t)); // <--- touch the "attr" here printf("step 2\n")

pthread_attr_setdetachstate(&attr, ...);

printf("step 3\n");

pthread_create(.., &attr, ...);

So what's the last "step" printed?

Signature · 2 lines
Best regards,
Dmitry Adamushko