Page 69 - DCAP103_Principle of operating system
P. 69
Principles of Operating Systems
Notes Objectives
After studying this unit, you will be able to:
• Explain concept of threads
• Discuss introduction to multi-threading in IDL
• Understand context switching
• Explain scheduling criteria
• Understand types of scheduling
• Explain scheduling algorithms
• Understand overview of thread scheduling
Introduction
A process is a program in execution. A process must have system resources, such as
memory and the underlying CPU. The kernel supports the illusion of concurrent execution
of multiple processes by scheduling system resources among the set of processes that are
ready to execute. On a multiprocessor, multiple processes may really execute concurrently.
This unit describes the composition of a process, the method that the system uses to switch
between processes, and the scheduling policy that it uses to promote sharing of the CPU.
It also introduces process creation and termination, and details the signal facilities and
process-debugging facilities.
3.1 Concept of Threads
Despite of the fact that a thread must execute in process, the process and its associated threads
are different concept. Processes are used to group resources together and threads are the entities
scheduled for execution on the CPU.
A thread is a single sequence stream within a process. Because threads have some of the properties
of processes, they are sometimes called lightweight processes. In a process, threads allow multiple
executions of streams. In many respect, threads are popular way to improve application through
parallelism. The CPU switches rapidly back and forth among the threads giving illusion that the
threads are running in parallel. Like a traditional process, i.e. process with one thread, a thread can
be in any of several states (Running, Blocked, Ready or terminated). Each thread has its own stack.
Since thread will generally call different procedures and thus a different execution history. This is
why thread needs its own stack. An operating system that has thread facility, the basic unit of
CPU utilization is a thread. A thread has or consists of a program counter (PC), a register set,
and a stack space.
Threads are not independent of one other like processes as a result threads
shares with other threads their code section, data section, OS resources also
known as task, such as open files and signals.
62 LOVELY PROFESSIONAL UNIVERSITY