newbee question

Jul 06, 2004 4 Replies

Hi, In Linux, how is the communication between user and kernel space happen?



In general RTOS, if we execute a system call from the user level, a trap would be generated to switch the mode to the kernel level and the system call would execute in privileged mode.How does this happen in Linux?



pl. correct me if i am wrong..



Tks Uday


"Uday Mullangi" ?ÈëÏû?ÐÂÎÅ :ccded9$ snipped-for-privacy@netnews.proxy.lucent.com...

happen? this happen only by system call

System calls.

Your general RTOS is a higher-end one if it uses traps to enter kernel mode. That's exactly how Linux does it, as well, though. There are some differences in how data is copied between user-space and kernel-space, but since I don't know what RTOS you're coming from, I can't be much more specific.

Steve Watt KD6GGD PP-ASEL-IA ICBM: 121W 56' 57.8" / 37N 20' 14.9" Internet: steve @ Watt.COM Whois: SW32 Free time? There's no such thing. It just comes in varying prices...

Depends on what you want, some ideas are:

- through /proc 'filesystem'

- through a device driver in /dev

- through shared memory

If you want to pass a great deal of data between user and kernel space then shared memory is the prefered option (faster), however communication through /dev is easier to setup and you cannot write to the same memory address...

Good luck, Freddy

In Linux you don't do this directly but you use library calls and macros provided with the OS (or compilers) both on the user land and on the system site.

The way it is done internally depends on the processor architecture. Of course using traps or "int" instructions is a usual way (in fact Kernel

2.6 uses "int" for older X86 processors and the newer "sysenter" instruction for new ones).

For self-made Kernel functions (I/O drivers etc.) you create device drivers in C. Same communicate with user land software via standard file I/O functions. Macros to install same and to move data from/to userland address space are provided with the Kernel and in userland they are available in any program language.

Read "Linux device drivers" by Rubini (available even online) to learn more.

-Michael

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required