0% found this document useful (0 votes)
18 views6 pages

Adobe Scan Sep 12, 2024

SELECTIVE CSE NOTES

Uploaded by

Anjan Das
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views6 pages

Adobe Scan Sep 12, 2024

SELECTIVE CSE NOTES

Uploaded by

Anjan Das
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

In Figure 3.

5 (a) process I starts its execution


finished its execution. Same as process 3 starts its execution only afte
only after process I
said to be serial process.
process 2 finished its execution. Therefore these process are
Consider the figure 3.5 (b),The execution time of process 1, process 2, process 3, ar
overlapped, so these are said to be concurrent process.

3.5 Threads Thread2


Thread 1

nrocess is divided in to number of light weight Thread 3


process ., Each light weight process is said to be a
thread. The thread has a program counter that keeps
the tracks of which instruction to execute next, it pr
has registers ,which hold its current working
variables. I kas a stack, which contains the execution Thread
1st stack
history
umber of threads can share an address space ,
open files and others resources. Same as number of
process can share physical memory , disks , printers Kernel
and other resources. Because threads have some of
the properties of process. Threads operates in many hreads
respects, in the same manner as process. Threads can
be in one of several states: Ready, Blocked, running terminated. Like process, Threads share
the CPU, and only one thread at a time is active (Running). Threads can create child threads,
unlike process , threads are not independent of one another. Because all threads can access
every address in the task. A thread can read (or) write over any other thread stacks.
Process Descrition and control 3.7

The human body performs a great variety of operations in concurrentlv., for example
seeing. touching, smelling, tasting and hearing can occur concurrently. An automobile can
he accelerating , turning, air conditioning, and playing music connectively. The programmer
specifies that application contain "Threads of execution". Eachthread designating portion of
programthat may be execute concurrently with other threads. This capability is called
multithreading.
Life eycle of thread:Athread is said to be in one of following several thread states.
Born State: A thread that has just created.
Ready state: The thread is waiting for processor (CPU)
Running: The system assigns the processor to the thread( i.e the thread being
executing)
Blocked state: The thread is waiting for an event to occur (or) waiting for an /O
4
device.
Sleep: A sleeping thread becomes ready after the designated sleep time expires.
Dead: The execution of the thread finished.
thread.
Considering the following figure 3.9 to understand the life cycle of a
Born

Ready

Ruqing

Blocked
Waiting (Sleeping) Dead

Figure 3.9 Life cycle of a thread.

Examples of threads
the programine
word processor: A programmer wish to type the text in word processor. Then
thread) the text is automaticany
Ppen aile in word processor , and typing the text( It is one mistakes,it
ormatting ( It is another thread),The text is automatically specifies the spelling
thread. 1yps
S another thread, and the file is automatically saved in the disk .it is another are threads. For
n afile is the saving these
process. Buttyping , Formatting. Spell checking
txample consider the figure 3.10
tthreads
he areWn
table,
tircad two Bserthreads.Tecord
atesynchronization
Tese Thread Thread
of functionality
Thread
thread threads
lel er tnreads
with in
10.Processes 9.
It 8. 7. (6. 5. A. 3. 3it I. Process
threadys
level activities.
Parallel execute.
Process other.
communicate each difficuit.
in requires
between System
Implementing
prOcesses.
betweentwExecution
o It the proccss.
It memory
process
e states: tahes takes takes
execution
table file, a
cQnsists threads of and
is callsprocesses more more more
nanagedmanaged main
kernel it Already are
moreloosely is areacantProcess
will are
a not time very tme
the loaded ways the and time (addressshare
process
effect suitableresources
information
level
discussed coupled. requiredcommunication
is slow.
to
D in
by andto terminate. to to
the
a switch complete
withshare create
run entirely
use inplement
threads bit space) same
for to to more
time space, another a
the in
of in memory section
system.
program each user threads: threads,
10. 9. 8. 7. 6. 5. 4. 3. 2.
processspace, 3.5 1.
When in and SuitableRequired
also Threads Systemthreads are threads.
Communication wo It
tExecution Less It
counter, so takes takes Threads
the user files. collected very Thread
needs need time
thread
a kernel space for fewer are calls shareeasy less less can Process
stack toOne is to
i<s try parallel tightly are the to time very terminate. time share
own thread lightweight
process. Descrition
is knows synchronizing resources, not between
implemen,
pointer, memory. to
fast. to
moved
private
kernel.
the in coupled. Switch create memory
is activities. required.
nothing trying
registers,
lo two
a
and
so betwèen and
ready thread
table,the
to it Because
threads
thread control3.13
about the is files.
modity
state state dCthViies
the
elc.
or one
3.12 Operating Systems

Threads
3.7 Processes and section 3.5. Now we are going to be discussed
about threads in
Already we discussed
multithreing.
S.7.y Multithreading smaller tasks, cach task is called a 'thread'. Numbe.
processisdivided into number of time is called 'multithreading .
Supporting
process execute at a Based onthe
Hhreads with in a
multithreading isthe additional capability of an operating
system. functionalit,
threads are divided into 4 categories these are.
Threads

Multiple Multiple
Process,one ProceSs,
thread per Multiple
process Threads

One process one One process


Thread multiple Thread

Figure 3.12
Oneprocess one thread: It is a traditional approach, in which the process maintains
one thread, so it is called single threaded approach. For example MS-DO8
operating system supports this type of approach.
2. One process, multiple threads: Inwhich a process Civided into number of threads
best example for this one is 'JAVA runtime environment'.
3. Multiple process, one thread per process: Anoperating system support multip#
user processes but only support one thread per process. Best example for this typ
is UNIX.
Î Multiple processes, multiple threads per process: In which each process divided
into nunber of threads, example for this type is windows 2000, Solaris LINUX.
Bhefits of a Thread
/A thread takes less time to terminate, than the process.
It takes less time to switch between two threads within the same
process.
It takes less ime lo creale a new thread within the
process.
Efficient communication between threads.
3.14 Onedting Syste ms
restart it is stored in the thread table. Consider the
to
The information needed
blocked suate.
below igure.
Thread Process Thread
Process

User
space

Kernal
space

Thread table Process table


Runtime system

Figure 3.13 User level thread

Adyantagés
U_¿r level threads allow each process to have its own scheduling algorithm.
not switch to the kernel
2. The entire process loaded in user space, so the process does
mode switches.
mode to do thread management.This saves the overhead of two
3. Useplevel threads can run on any operating system.
Disadvantages
1./Whh user level thread executes a system call, not only the particular thread blocked.
a> of the threads with in the process are blocked.
2. In user level threads, only a single thread with in a process can execute at a time. So
multi pfocessing is can't implemented.
Kernelevel Threads
In Kgfnel level threads the kernel does total work of thread movement. There is no thread
table in each process. The kernel has a thread table that keeps track of all the threads i
system. When a thread wants tocreate a new thread or destroy any existing thread, it makes
a kernel call, which takes the action. .
The kernel's thread table holds each thread registers, state and other information. The
information is the same as with user level threads, but it is now in the kernel instead of the
user space. Consider the below figure for better understanding.
Process Descrition and control ¢3.15

Thread Process Thread


Process

User
space

Kernal Kernal
space

Thread table
Process table

Ligure 3.J4
Advantages
Lthe kernel can simultaneously schedule a multiple threads from the same process
on multiple processors. It means it supports multi processing where as user level
threads can't support this.
2 A thread in a process is blocked; the kernel can schedule another thread of the same
process.

3. Kernel routines themselves can be multi threaded.


4 Scheduling by kernel is done on a thread bus.

Disadvantages
T. More cost for creating and destroying threads in the kernel.
2. The transfer of control from one thread to another with in the same
process requires
a mode switch to the kernel.

Combined approaches
1f we combine the both approaches (user level, kernel level) then we get the
advantages of
both. Some operating systems provide this type of facility. In combined system thread creation
Is done completely in user space. Best example for this approach is 'Solaris"

3.8 Symmetric Multi Processing


1wOor more similar processors connected via a high bandwidth link and managed by oe
Pelaung System, where each processor has equal access to I/O devices, if a system having
tnis type of facility we can say that it is a symmetric multiprocessing environment

You might also like