im new to OS.
i want somebody to please give me the differences between the kernel mode and the user mode.

are these block in memory ?

i did some research on the internet and all i understood was that kernel mode is protected from the user and it is where the operating system is and the user mode is not protected.

but can anybody give some examples to clarify this. and can you please explain what does it mean to say that to update linux you can simply download the kernel ! ( is the kernel a software :S )

thank you so much in advance

A kernel is the main program or component of an operating system, it's the thing that does all the work, without it you have no operating system. Linux is actually nothing more than a kernel; the programs that make up the rest of the operating system are generally GNU software, so the entire operating system is usually referred to as GNU/Linux.

User mode is the normal mode of operating for programs. Web browsers, calculators, etc. will all be in user mode. They don't interact directly with the kernel, instead, they just give instructions on what needs to be done, and the kernel takes care of the rest. Kernel mode, on the other hand, is where programs communicate directly with the kernel. A good example of this would be device drivers. A device driver must tell the kernel exactly how to interact with a piece of hardware, so it must be run in kernel mode. Because of this close interaction with the kernel, the kernel is also a lot more vulnerable to programs running in this mode, so it becomes highly crucial that drivers are properly debugged before being released to the public.

Finally, yes, updating Linux simply involves installing a new kernel because, as I said earlier, that's all 'Linux' really is. If you want to update the GNU programs that make up the rest of the operating system, you're going to have to use the tools that your Linux distribution provider supplied with the operating system.

Dear John , first i wanna thank you for your reply, now here are my questions :

A kernel is the main program or component of an operating system,(so you're sayin that the operating system is
made of many software/programs put together and the kernel is the main program)?

i read that any os has 2 main functionalities: extended machine(abstraction) and resources management.

"it's the thing that does all the work" (by work you mean : its responsible for the 2 functionalities i mentioned
earlier?)


what are the "GNU software"? ( i googled and found that these are free software but i didnt understand much).

"User mode is the normal mode of operating for programs.web browsers ".. (is "use mode" a place in memory ?
since the web browsers and calculators are in the user mode,it means they are installed in the portion of memory
that is specified to the user mode ?)

if i download any software from the internet, lets say "sticky notes software" , will it get installed in the "user mode?"

if i buy a printer and i put the driver cd in my laptop, will it get installed in the "kernel mode"?

so can we say that hard disk is partitioned into addresses for user mode and ones for kernel mode?

Sorry if im askin too much, but i bought i book and im learning about os and im totally new to this topic

A kernel is the main program or component of an operating system,(so you're sayin that the operating system is
made of many software/programs put together and the kernel is the main program)?

Yes. Any sufficiently-advanced operating system requires a number of programs to handle processes, memory management, disk usage, drivers, etc. And then it's usually not uncommon to include software that the user can use so they don't have to start from scratch.

i read that any os has 2 main functionalities: extended machine(abstraction) and resources management.

"it's the thing that does all the work" (by work you mean : its responsible for the 2 functionalities i mentioned
earlier?)

Abstraction is usually handled by higher-up processes (such as a GUI), although the kernel is mainly responsible for resources management (it also has processes that help it out). The kernel isn't concerned with the abstraction of an interface, in fact, it's more concerned with handling the actual commands that make up the program.

what are the "GNU software"? ( i googled and found that these are free software but i didnt understand much).

GNU is a recursive acronym for GNU's Not Unix. It's basically a project started about 24 years ago whose goal was to develop a Unix-like operating system. The kernel was never really finished, so when Linus Torvalds wrote the Linux kernel, they adopted it to complete their operating system.

"User mode is the normal mode of operating for programs.web browsers ".. (is "use mode" a place in memory ?
since the web browsers and calculators are in the user mode,it means they are installed in the portion of memory
that is specified to the user mode ?)

Yup. It's called 'user space' and 'kernel space', see http://en.wikipedia.org/wiki/User_space

if i download any software from the internet, lets say "sticky notes software" , will it get installed in the "user mode?"

if i buy a printer and i put the driver cd in my laptop, will it get installed in the "kernel mode"?

You can't really control which 'mode' it runs in. The way the programmer wrote the software will determine whether the program must run in user mode or kernel mode.

so can we say that hard disk is partitioned into addresses for user mode and ones for kernel mode?

No, not really. If you're really interested, study the basics of how a kernel module is written and how this is different from a regular program. Based on the calls that the program makes, the kernel determines whether it must be run in kernel or user mode.

well again , your answers were EXTREMELY HELPFUL...

one more question :
"If you're really interested, study the basics of how a kernel module is written and how this is different from a regular program."

do you have any idea where i can find information about that ?

I've never really done any kernel module programming, but I'll show you an example. Here's a typical 'hello world' program written to run in user mode. All it does is print out 'hello world' and then exit.

#include <stdio.h>

int main()
{
   printf("Hello, world!\n");

   return 0;
}

By contrast, here's a similar program running in kernel mode that prints out "Hello, world" and "Goodbye, world" to the kernel log. The code is taken from The Linux Kernel Module Programming Guide.

/*  
 *  hello-1.c - The simplest kernel module.
 */
#include <linux/module.h>	/* Needed by all modules */
#include <linux/kernel.h>	/* Needed for KERN_INFO */

int init_module(void)
{
	printk(KERN_INFO "Hello world 1.\n");

	/* 
	 * A non 0 return means init_module failed; module can't be loaded. 
	 */
	return 0;
}

void cleanup_module(void)
{
	printk(KERN_INFO "Goodbye world 1.\n");
}

well im gettin the hang of it now....you made things much clearer :)

would you mind if i keep in contact with you ?

here's my email address <email snipped> send me a msg to my hotmail if you dont mind us being in contact.

thank you for everything:)

No problem, glad to be of help.

Note that it's against the forum policy to post email addresses in your posts, although feel free to contact me with the email address listed on my profile.

oopss, sorry i totally forgot :$

execuse me guys

Hello john :)

tis me again :) hope you're doing fine.

well, i have a couple of questions:

1- you told me that linux is the kernel itself, well about windows ? is the windows xp , for instance, considered as the kernel

2- i read this and i didnt really understand what it means , i hope you could help in explaining it to me:

" the distinction betwee user and kernel mode is sometimes blurred in embedded systens (which may not have kernel mode) or interpreted systems ( such as java-based operating systems that use interpretation, not hardware to seperate the components".

>is the windows xp , for instance, considered as the kernel
"Windows XP" refers to the entire operating system. Since everything is closed-source and developed my Microsoft, there's really no reason to have a name for it, although I guess you would refer to it as the Windows NT kernel (as the XP kernel came from the NT series).

>i read this and i didnt really understand what it means , i hope you could help
>in explaining it to me

Embedded systems have a very simple environment for running programs (and in many cases there is no kernel or operating system). Because of this simple environment, it's difficult to separate purely user-based software from kernel-based software as the hardware is usually meant for a single type of software.

Interpreted systems are special because the programs running in them aren't processed by the kernel of the base operating system. For example, Java programs have to run inside a runtime environment, which is like a kernel running inside another kernel, and as such they communicate with the virtual kernel. This makes it harder to distinguish between kernel and user mode.

oh alright, i see what you mean.

well,let's say i bought this new printer, and i plugged it in my laptop, of course it wont work cz the operating system doesnt know how to communicate with this new hardware,

so i install the cd.
well, as i understood from what you told me, the software will be loaded in the kernel to protect it from the user.

my first question: let's assume the cd is loaded in the user mode, how can a user access it , and how can it modify it and mess with it ?

second, let's say i want to print something.
can you tell me how things happen in details in the low level.

i mean, once i click print on the software that i downloaded, how will the os know that i want to print ? and how will the os get the printing job done?

again, thank you so much for replying fast, you are really helping me a lot !

>the software will be loaded in the kernel to protect it from the user.

No, the reason it's loaded into the kernel is because the driver needs direct communication with the kernel and vice versa. It has nothing to do with 'protection' from the user, although it's true that there generally isn't too much communication between a kernel-based program and the user.

>let's assume the cd is loaded in the user mode, how can a user access it , and how can it
>modify it and mess with it ?

In this case, installing the program doesn't actually require running it. An installer program running in user mode, naturally, installs it onto the system. It is then run from your hard drive.

>i mean, once i click print on the software that i downloaded, how will the os know that i
>want to print ? and how will the os get the printing job done?

It's somewhat OS-dependent, but generally what happens is that software sends the printer spooler a document. The printer spooler then decides if the printer specified is local or network-based, and will then send it to the appropriate device. The kernel handles the send requests to a device, and it in turn communicates with the driver, which finally communicates with the printer hardware. That's the basic idea.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.