Re: user and kernel space ?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

x86 actually has 4 protection levels that OS designers can play with, 
but Linux and every other UNIX, as far as I know, only use 0 (kernel) 
and 3 (user). The purpose is to disallow certain untrusted programs from 
performing certain dangerous operations without being somehow checked by 
the operating system. The most important of these managed operations is 
reading/writing to/from memory segments that belong to other processes. 
Processes that run at ring 3 cannot access memory that is not mapped 
into their own virtual address space, i.e. memory that does not belong 
to them. When they try, they receive Segmentation Violation signal, and 
the process terminates with a core file. On the other hand, the OS, 
which operates at ring 0, can read and write from memory belonging to 
any process. Other things that are protected the x86 IN and OUT 
instructions that interact directly with the hardware peripherals at an 
extremely low level. I'm sure there's more, but I can't remember :)

There is a tremendous benefit from implementing things in kernel space, 
especially if there is a lot of copying buffers going on, like for 
network I/O, or lots of system calls going on.

As far as I know, X11 is a userspace app. It would be a Really Bad 
Idea(tm) to implement it otherwise. Code that runs in kernel space must 
be absolutely and truly bug free, and so kernel code must be very, very 
careful to check the validity of all parameters passed in to them, to 
check that buffers are sufficiently large, etc... Kernel space 
programmin is very unforgiving. Besides, any performance gains are 
probably not worth the tradeoff in reliability, and I'm sure the X team 
gets around that with just great programming.

If your system appears to hang, but the start menu comes up, then I 
think that that's pretty good evidence that your system is not really 
hung :) To test this, try Ctrl-Alt-F1 to bring up a virtual terminal. If 
you can, the kernel is completely happy and it is just X, or your app 
that is misbehaving. Ctrl-Alt-F7 to get your GUI back. As a general 
rule, if you think your Linux box is hung, it isn't :)

In my previous life, I did a lot of Windows programming, and yes, a 
*lot* of things that don't need to be in kernel space were implemented 
there. Many parts of the GUI are, because on x86 it is a relatively 
expensive operation in terms of clock cycles to switch from user to 
kernel mode and back again. The people at Microsoft thought that they 
could make their GUI more responsive by implementing parts of it in 
kernel space in order to avoid having to switch back and forth.

Check out the IA32 Architecture docs from Intel, or better yet, the 
Coriolis book on the 2.4 kernel.

Have fun,

Don

Mcen navaraj wrote:

>hi,
>
>what is the use of two privilege level ?
>is there any performance is increase if we implement
>some
>program in the kernel space ?
>
>in linux please tell me in which space ( user or
>kernel ) 
>the X11 is implemented ?
>why i am asking this question means if sometimes the
>system
>hangs , only the start menu ( that is k in kde ) is
>quickly 
>popup's.Another reason for asking this question is my
>friend told the desktop in windows95 is implemented in
>the
>kernel space.
>
>please give me some useful info ( anything related to
>the
>windows or linux ).
>
>thanks
>bye
>
>
>__________________________________________________
>Do You Yahoo!?
>Yahoo! Finance - Get real-time stock quotes
>http://finance.yahoo.com
>
>
>
>_______________________________________________
>Redhat-devel-list mailing list
>Redhat-devel-list@redhat.com
>https://listman.redhat.com/mailman/listinfo/redhat-devel-list
>
>
>  
>




_______________________________________________
Redhat-devel-list mailing list
Redhat-devel-list@redhat.com
https://listman.redhat.com/mailman/listinfo/redhat-devel-list

[Index of Archives]     [Kernel Newbies]     [Red Hat General]     [Fedora]     [Red Hat Install]     [Linux Kernel Development]     [Yosemite News]

  Powered by Linux