25.06.2013 Views

Slackware Linux Basics - Huihoo

Slackware Linux Basics - Huihoo

Slackware Linux Basics - Huihoo

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 4. General concepts<br />

This chapter gives an introduction to some general UNIX and GNU/<strong>Linux</strong> concepts. It is important to read this chapter<br />

thoroughly if you do not have any UNIX or GNU/<strong>Linux</strong> experience. Many concepts covered in this chapter are used<br />

in this book and in GNU/<strong>Linux</strong>.<br />

4.1. Multitasking<br />

Introduction<br />

One of UNIX's traditional strengths is multitasking. Multitasking means that multiple programs can be run at the same<br />

time. You may wonder why this is important, because most people use only one application at a time. Multitasking is a<br />

bare necessity for UNIX-like systems. Even if you have not started any applications, there are programs that run in the<br />

background. For instance, some programs provide network services, while others show a login prompt and wait until<br />

a user logs in on a (virtual) terminal. Programs that are running in the background are often called daemon processes 1 .<br />

Processes and threads<br />

After a program is loaded from a storage medium, an instance of the program is started. This instance is called a<br />

process. A process has its own protected memory, named the process address space. The process address space has<br />

two important areas: the text area and the data area. The text area is the actual program code; it is used to tell the system<br />

what to do. The data area is used to store constant and runtime data. The operating system gives every process time to<br />

execute. On single processor systems processes are not really running simultaneously. In reality a smart scheduler in<br />

the kernel divides CPU time among processes, giving the illusion that processes run simultaneously. This process is<br />

called time-sharing. On systems with more than one CPU or CPU cores, more than one process can run simultaneously,<br />

but time-sharing is still used to divide the available CPU time among processes.<br />

New processes are created by duplicating a running process with the fork system call. Figure 4.1, “Forking of a<br />

process” shows a fork() call in action schematically. The parent process issues a fork() call. The kernel will respond<br />

to this call by duplicating the process, and naming one process the parent, and the other process the child.<br />

Figure 4.1. Forking of a process<br />

1 The word daemon should not to be confused with the word demon, the word daemon refers to supernatural beings in Greek mythology.<br />

15

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!