Skip to contentSkip to conversation

rt context

Xenomai-help Peter Hua 1 participant 1 message Jan 17, 2012

lore
Share & tools
lore

Peter Hua

author
#0 lore raw

Thank you, Philippe. This issue is resolved. One follow-on question: the CSW field of /proc/Xenomai/stat indicates the number of switches between user-mode and kernel-mode, correct?

Regards,
Peter

-----Original Message-----
From: Philippe Gerum [mailto:[email protected]]
Sent: Tuesday, January 17, 2012 12:37 AM
To: Peter Hua
Cc: [email protected]
Subject: Re: help rejected

Quoted 5 lines · Peter Hua

Hi Philippe,

I retract my previous statement. The call to rtdm_in_rt_context() returned '1'. So the task was in RT context, but I don't understand how? Is there a way to force it to be non-rt?

There is no way you can do that from kernel space; mode switches are implemented during the syscall transition between user and kernel. Memory mapping operation is usually part of the init chores of a driver, in which case this would be a non-issue since RTDM runs the .open call in non-rt kernel context (.open_rt is deprecated and even removed in latest versions).

If your code tries to issue this mapping call from .ioctl_rt, then you should move this particular ioctl command to the .ioctl_nrt handler instead. Xenomai first tries the .ioctl_rt handler if present, then downgrades to .ioctl_nrt if the former returned -ENOSYS. So, if both .ioctl_rt and .ioctl_nrt have to coexist in your driver, then you should follow this pattern:

static int foo_ioctl_rt(struct rtdm_dev_context *context,
rtdm_user_info_t *user_info, unsigned int cmd, void *arg)

{
	switch (cmd) {

	case IOC_WHATEVER_MMAP:
		/* Tell Xenomai to offload to _nrt handler. */
		return -ENOSYS;
	...
	}
}

static int foo_ioctl_rt(struct rtdm_dev_context *context,
rtdm_user_info_t *user_info, unsigned int cmd, void *arg)

{
	switch (cmd) {

	case IOC_WHATEVER_MMAP:
		ret =rtdm_mmap_to_user(...);
	...
	}
}

PS: I see you are now subscribed to Xenomai-help, so you should be allowed to post there.

Quoted 20 lines

Regards,
Peter

-----Original Message-----
From: Philippe Gerum [mailto:[email protected]]
Sent: Monday, January 16, 2012 1:53 PM
To: Peter Hua
Cc: [email protected]
Subject: Re: help rejected

Quoted 3 lines · Peter Hua

Hello,

Quoted 7 lines
Quoted 2 lines

My request for help was rejected. Also, I did not get a confirmation for the subscription request. Please help.

I'll check your subscription asap, but for the time being, the answer to your question is that you may not call that routine from a real-time context. This is callable only from kernel module init, and any other plain linux (kernel) context, not from Xenomai -rt context in

kernel space.

Quoted 19 lines
Quoted 16 lines

Regards,
Peter

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of [email protected]
Sent: Friday, January 13, 2012 12:17 PM
To: [email protected]
Subject: rtdm_mmap_to_user call failed

Quoted 3 lines

You are not allowed to post to this mailing list, and your message has been automatically rejected. If you think that your messages are being rejected in error, contact the mailing list owner at

Quoted 9 lines

[email protected].

Quoted 1 line

--
Philippe.

--
Philippe.