Handbook of Computer Science(cs) and IT

Threads

A thread is a basic unit of CPU utilisation. A thread comprises a dimensional program counter , a register set and a stack. It share  with other threads belonging to the same process its code section, data section and other system resources such as open files and signals tradition

control, it can perform more than one task at a time.

Multithreading

An application typically is implemented as a separate process with several threads of control. In some situations, a single application may be required. to perform several similar tasks. e.g., a web server accepts client request for web pages, images, sound and so on. A busy web server may have several of clients concurrently accessing it. If the web server run as a traditional single threaded process, it would be able to service only one client at a time.

The amount of time that a client might have to wait for its request to be serviced could be enormous. So, it is efficient to have one process the: contains multiple threads to serve the same purpose.

This approach would multithreaded the web server process, the server would create a separate thread that would listen for client requests, when a request was made rather than creating another process, it would create another thread to service the request.

Multithreading Model

There are two types of threads

(i) User threads                                 (ii) Kernel threads

Kernel Threads

 

Kernel threads are supported and managed directly by the operating system .

 

User Threads

They are above the kernel and they are managed without kernel support.

There are three common ways of establishing relationship between threads and kernel threads

 

(a) Many-to-many model   (b) One-to-one mode

 

 

 

One-to-one model maps each user thread to corresponding kernel Threads.

  • Many-to-many model multiplexes many user threads to a smaller or equal ual number of kernel threads,
  • Many-to-one model maps many user threads to single kernel threads.

Key Point

  • User level threads are threads that are visible to the programmer and unknown to the Kernel.
  • User level threads are faster to create and manage than that of Kernel threads.

Process

A process is a program in execution. A process is more than the program code i.e., text section. It also includes the current activity as represented by the value of the program counter and the contents of the processor’s register.

Max

Process in Memory

Each process is represented in the OS by a Process Control Block (PCB) also called a task control block.

 

As processes enter the system, they are put  into a job queue, which consists of all processes in the system.

The processes that are residing in main memory and are ready and waiting to execute are kept on a list called the ready queue.

 

KeyPoints                                                                                                                                                      ——–

  • The list of processes waiting for a particular I/O device is called a device Each device has it’s own device queue.
  • I/O O bound process is one that spends more of its time doing I/O rather than it spends doing computations.
  • A CPU bound process is one which uses more of its time doing computations rather than it spends doing I/O activities.

 

Schedulers

A process migrates among various scheduling queues throughout its lifetime. The OS must select for scheduling purposes, processes from these queues in some fashion. The selection process is carried out by the appropriate scheduler.

Long Term and Short Term Schedulers

  • A long term scheduler or job scheduler selects processes from job pool (mass storage device, where processes are kept for later execution) and loads them into memory for execution.
  • A short term scheduler or CPU scheduler, selects from the main memory among the processes that are ready to execute and allocates the CPU to

one of them

  • The long term scheduler controls the degree of multiprogramming (the number of processes in memory).

Note Mid-term scheduler uses the concept of swapping.

 

Dispatcher

Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95

Leave a Reply

Your email address will not be published. Required fields are marked *