You are on page 1of 3

Processes

CEIT313 Use of Operating Systems

Processes & Threads
Week 03

 Early computer systems allowed only one
program to be executed at a time and this
program had complete control of the system
and had access to all the system's resources.
 In contrast, current-day computer systems
allow multiple programs to be loaded into
memory and executed concurrently.
 A process is a program in execution and is
the unit of work in a modern time-sharing
system.
Computer Education & Instructional Technology
CEIT313 Use of Operating Systms

Slide 2 of 18

User & System Tasks

Process Concept

 The more complex the operating system is, the more it is
expected to do on behalf of its users.
 An OS’s main concern is the execution of user programs, it
also needs to take care of various system tasks that are
better left outside the kernel itself.
 A system therefore consists of a collection of processes:

 A question that arises in discussing operating systems
involves what to call all the CPU activities.
 A batch system executes jobs, whereas a time-shared
system has user programs, or tasks.
 Even on a single-user system such as Microsoft Windows, a
user may be able to run several programs at one time:


operating system processes executing system code and
user processes executing user code.

 Potentially, all these processes can execute concurrently,
with the CPU (or CPUs) multiplexed among them.
 By switching the CPU between processes, the operating
system can make the computer more productive.

Computer Education & Instructional Technology
CEIT313 Use of Operating Systms

Slide 3 of 18

Process Concept (Cont’d)



a word processor,
a web browser, and
an e-mail package.

 Even if the user can execute only one program at a time, the
operating system may need to support its own internal
programmed activities, such as memory management.
 In many respects, all these activities are similar, so we call
all of them processes.
Computer Education & Instructional Technology
CEIT313 Use of Operating Systms

Slide 4 of 18

Process in Memory

 A process is a program in execution.
 A process is more than the program code (text
section).
 It also includes the current activity, as represented by
the value of the program counter and the contents of
the processor's registers.
 A process generally also includes the process stack,
which contains temporary data (such as function
parameters, return addresses, and local variables), and
a data section, which contains global variables.
 A process may also include a heap, which is memory
that is dynamically allocated during process run time.

Computer Education & Instructional Technology
CEIT313 Use of Operating Systms

Slide 5 of 18

Computer Education & Instructional Technology
CEIT313 Use of Operating Systms

Slide 6 of 18

1

 Ready.  If a process has multiple threads of control.  Waiting. and other operating-system resources. With a program counter specifying the next instruction to execute and a set of associated resources. The process is being created. Such as a file containing a list of instructions stored on disk (often called an executable file)  A process is an active entity.  The state of a process is defined in part by the current activity of that process. heap.  A program becomes a process when an executable file is loaded into memory. it changes state. Computer Education & Instructional Technology CEIT313 Use of Operating Systms Slide 10 of 18 Threads  A thread is a basic unit of CPU utilization  It comprises a thread ID.  Terminated.out.  Two common techniques for loading executable files Computer Education & Instructional Technology CEIT313 Use of Operating Systms Computer Education & Instructional Technology CEIT313 Use of Operating Systms Slide 7 of 18  Double-clicking an icon representing the executable file and  Entering the name of the executable file on the command line (as in program. such as open files and signals. data section.  A traditional (or heavyweight) process has a single thread of control. and a stack.  It shares with other threads belonging to the same process its code section. and stack sections vary. it can perform more than one task at a time. a program counter. Instructions are being executed. Computer Education & Instructional Technology CEIT313 Use of Operating Systms Slide 11 of 18 Computer Education & Instructional Technology CEIT313 Use of Operating Systms Slide 12 of 18 2 .Process Concept (Cont’d) Process Concept (Cont’d)  We emphasize that a program by itself is not a process  A program is a passive entity. The process is waiting for some event to occur (such as an I/O completion or reception of a signal). The process has finished execution. however.  It is important to realize that only one process can be running on any processor at any instant.  Many processes may be ready and waiting.  Each process may be in one of the following states: Computer Education & Instructional Technology CEIT313 Use of Operating Systms Slide 9 of 18 Diagram of Process State  New. a register set.) Slide 8 of 18 Separate Processes Process State  More than one user may be running different copies of a mail program.  Each of these is a separate process  While the text sections are equivalent.exe or a. The process is waiting to be assigned to a processor. or the same user may invoke many copies of a web browser program.  Running. the data.  As a process executes.

3. where threads may be running in parallel on different processors.  The benefits of multithreading can be greatly increased in a multiprocessor architecture. Utilization of multiprocessor architectures Computer Education & Instructional Technology CEIT313 Use of Operating Systms Slide 14 of 18 Responsiveness Resource Sharing  Multithreading an interactive application may allow a program to continue running even if part of it is blocked or is performing a lengthy operation  This increases responsiveness to the user.  In Solaris. Computer Education & Instructional Technology CEIT313 Use of Operating Systms Slide 17 of 18 Computer Education & Instructional Technology CEIT313 Use of Operating Systms Slide 18 of 18 3 .Single-threaded and Multithreaded Processes The Benefits  The benefits of multithreaded programming can be broken down into four major categories: 1. Computer Education & Instructional Technology CEIT313 Use of Operating Systms Slide 13 of 18 Responsiveness. 2. and context switching is about five times slower.  By default.  A single threaded process can only run on one CPU. for example. a multithreaded web browser could still allow user interaction in one thread while an image was being loaded in another thread. Computer Education & Instructional Technology CEIT313 Use of Operating Systms Computer Education & Instructional Technology CEIT313 Use of Operating Systms Slide 15 of 18 Slide 16 of 18 Economy Utilization of multiprocessor architectures  Allocating memory and resources for process creation is costly. threads share the memory and the resources of the process to which they belong.  Multithreading on a multi-CPU machine increases concurrency.  In general it is much more time consuming to create and manage processes than threads. it is more economical to create and context-switch threads.  For instance. no matter how many are available. Economy. 4. creating a process is about thirty times slower than is creating a thread. Resource sharing.  The benefit of sharing code and data is that it allows an application to have several different threads of activity within the same address space.  Because threads share resources of the process to which they belong.