Switch from Kernel mode to User mode

Trium-virate used Ask the Experts™
How do I switch from Kernel mode to User mode ? I need to call a user mode program from the kernel.
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
For a number of reasons, it is impossible for kernel code to cause a process to switch to user mode and then back while retaining control.

Also, there is no such thing in unix as calling a program.  Calling means you run dome code and get control back when it is done.  In unix, the best you can do is exec a program, which means it starts running, but you never get control back; the process simply evaporates when the program is done.

So when people want their kernel code to cause some user space stuff to happen, they have a separate process standing by waiting for communication from said kernel code that something needs to be done.  They stand by via a system call that sleeps most of the time and returns when it is time to do the work.

But it's pretty unusual actually to need to be in user mode.  Maybe all you want is to be in the user address space.  If so, a simple set_fs(get_ds()) will do that.
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:

Accept: bryanh {http:#7708597}

Please leave any comments here within the next seven days.

EE Cleanup Volunteer

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial