SlideShare une entreprise Scribd logo
1  sur  52
OPERATING SYTEMS
       B.TECH II YR (TERM 08-09)
          UNIT 2 PPT SLIDES
TEXT BOOKS:
Operating System Concepts- Abraham Silberchatz,
   Peter B. Galvin, Greg Gagne 7th Edition, John
   Wiley
Operating systems- A Concept based Approach-
   D.M.Dhamdhere, 2nd Edition, TMH.

No. of slides: 52
INDEX
               UNIT 2 PPT SLIDES
S.NO. TOPIC                 LECTURE NO. PPTSLIDES
1. Process concepts threads     L9    L9.1 to L9.10
2. scheduling-criteria alg      L10   L10.1 to L10.7
4. scheduling-criteria alg      L11   L11.1 to L11.7
5. Algorithms evaluation        L12   L12.1 to L12.6
5. Thread scheduling            L13   L13.1 to L13.11
6. Case studies UNIX,LINUX      L14   L14.1 to L14.4
7. Windows                      L15  L15.1 to L15.2
8. REVISION                     L16
Process Concept
• An operating system executes a variety of
  programs:
  – Batch system – jobs
  – Time-shared systems – user programs or tasks
• Textbook uses the terms job and process
  almost interchangeably
• Process – a program in execution; process
  execution must progress in sequential fashion
• A process includes:
  – program counter
  – stack
  – data section
Process State

• As a process executes, it changes state
  – new: The process is being created
  – running: Instructions are being executed
  – waiting: The process is waiting for some event
    to occur
  – ready: The process is waiting to be assigned
    to a processor
  – terminated: The process has finished
    execution
Diagram of Process State
Process Control Block (PCB)
Information associated with each process
• Process state
• Program counter
• CPU registers
• CPU scheduling information
• Memory-management information
• Accounting information
• I/O status information
Process Control Block (PCB)
CPU Switch From Process to Process
Process Scheduling Queues
• Job queue – set of all processes in the
  system
• Ready queue – set of all processes
  residing in main memory, ready and waiting
  to execute
• Device queues – set of processes waiting
  for an I/O device
• Processes migrate among the various
  queues
Ready Queue And Various I/O Device Queues
Representation of Process Scheduling
Schedulers
• Long-term scheduler (or job scheduler) –
  selects which processes should be brought
  into the ready queue
• Short-term scheduler (or CPU scheduler) –
  selects which process should be executed
  next and allocates CPU
Producer-Consumer Problem
• Paradigm for cooperating processes,
  producer process produces information that
  is consumed by a consumer process
  – unbounded-buffer places no practical limit on
    the size of the buffer
  – bounded-buffer assumes that there is a fixed
    buffer size
Bounded-Buffer – Shared-Memory Solution
• Shared data
       #define BUFFER_SIZE 10
       typedef struct {
          ...
       } item;

       item buffer[BUFFER_SIZE];
       int in = 0;
       int out = 0;
• Solution is correct, but can only use
  BUFFER_SIZE-1 elements
Bounded-Buffer – Producer
while (true) {
   /* Produce an item */
        while (((in = (in + 1)
% BUFFER SIZE count) == out)
      ;   /* do nothing -- no
free buffers */
    buffer[in] = item;
    in = (in + 1) % BUFFER
SIZE;
Bounded Buffer – Consumer
while (true) {
         while (in == out)
                ; // do nothing
-- nothing to consume

      // remove an item from the
buffer
      item = buffer[out];
      out = (out + 1) % BUFFER
SIZE;
Scheduling Criteria
• CPU utilization – keep the CPU as busy as possible
• Throughput – # of processes that complete their
  execution per time unit
• Turnaround time – amount of time to execute a
  particular process
• Waiting time – amount of time a process has been
  waiting in the ready queue
• Response time – amount of time it takes from when
  a request was submitted until the first response is
  produced, not output (for time-sharing environment)
Scheduling Algorithm Optimization
             Criteria
•   Max CPU utilization
•   Max throughput
•   Min turnaround time
•   Min waiting time
•   Min response time
First-Come, First-Served (FCFS) Scheduling


             ProcessBurst Time
                  P1      24
                 P2       3
                  P3      3
• Suppose that the processes arrive in
  the order: P1 , P2 , P3
  The Gantt Chart for the schedule is:
               P1              P2        P3


      0                   24        27        30
FCFS Scheduling (Cont)
Suppose that the processes arrive in the order
                   P2 , P3 , P 1
• The Gantt chart for the schedule is:
  Waiting time for P1 = 6; P2 = 0; P3 = 3
• Average waiting time: (6 + 0 + 3)/3 = 3
• Much better than previous case
• Convoy effect short process behind long process
               P2       P3             P1


           0        3        6               30
Shortest-Job-First (SJF)
           Scheduling
• Associate with each process the length of
  its next CPU burst. Use these lengths to
  schedule the process with the shortest
  time
• SJF is optimal – gives minimum average
  waiting time for a given set of processes
  – The difficulty is knowing the length of the next
    CPU request
Determining Length of Next CPU Burst
• Can only estimate the length
• Can be done by using the length of previous CPU bursts,
  using exponential averaging




  τ n = 1 = α t n + ( 1 − α )τ n .
         1. t n = actual length of n th CPU burst
         2. τ n +1 = predicted value for the next CPU burst
         3. α , 0 ≤ α ≤ 1
         4. Define :
Examples of Exponential Averaging
∀ α =0
    τn+1 = τn
  – Recent history does not count
∀ α =1
  – τn+1 = α tn
  – Only the actual last CPU burst counts
• If we expand the formula, we get:
    τn+1 = α tn+(1 - α)α tn -1 + …
             +(1 - α )j α tn -j + …
             +(1 - α )n +1 τ0


• Since both α and (1 - α) are less than or equal
Priority Scheduling
• A priority number (integer) is associated with each process
• The CPU is allocated to the process with the highest priority
  (smallest integer ≡ highest priority)
   – Preemptive
   – nonpreemptive
• SJF is a priority scheduling where priority is the predicted next
  CPU burst time
• Problem ≡ Starvation – low priority processes may never
  execute
• Solution ≡ Aging – as time progresses increase the priority of
  the process
Round Robin (RR)
•   Each process gets a small unit of CPU time (time quantum), usually 10-100
    milliseconds. After this time has elapsed, the process is preempted and
    added to the end of the ready queue.
•   If there are n processes in the ready queue and the time quantum is q, then
    each process gets 1/n of the CPU time in chunks of at most q time units at
    once. No process waits more than (n-1)q time units.
•   Performance
      – q large ⇒ FIFO
      – q small ⇒ q must be large with respect to context switch, otherwise
         overhead is too high
    Process         Burst Time
                    P1      24
                    P2       3
                                     P1       P2       P3        P1        P1     P1    P1    P1
                    P3      3
                                 0        4        7        10        14        18 22    26    30
    The Gantt chart is:
    Typically, higher average turnaround than SJF, but better response
Time Quantum and Context Switch Time
Multilevel Queue Scheduling




Multilevel Feedback Queues   NUMA and CPU Scheduling
Algorithm Evaluation
• Deterministic modeling – takes a particular
  predetermined workload and defines the
  performance of each algorithm for that
  workload
• Queueing models
• Implementation
Evaluation of CPU schedulers by
           Simulation
Dispatch Latency
Time-Slicing
Since the JVM Doesn’t Ensure Time-
  Slicing, the yield() Method
May Be Used:

 while (true) {
    // perform CPU-intensive task
    ...
    Thread.yield();
 }
Thread Priorities

  Priority         Comment
Thread.MIN_PRIORITY        Minimum Thread
  Priority
Thread.MAX_PRIORITY           Maximum Thread
  Priority
Thread.NORM_PRIORITY          Default Thread
  Priority

Priorities May Be Set Using setPriority() method:
  setPriority(Thread.NORM_PRIORITY + 2);
Solaris 2 Scheduling
User Threads
• Thread management done by user-level
  threads library

• Three primary thread libraries:
     – POSIX Pthreads
     – Win32 threads
                  Kernel
     – Java threads                 Threads
 •   Supported by the Kernel

 •   Examples
      –   Windows XP/2000
      –   Solaris
      –   Linux
      –   Tru64 UNIX
      –   Mac OS X
Thread Scheduling
• Distinction between user-level and kernel-level
  threads
• Many-to-one and many-to-many models, thread
  library schedules user-level threads to run on
  LWP
  – Known as process-contention scope (PCS) since
    scheduling competition is within the process
Kernel thread scheduled onto available CPU is
 system-contention scope (SCS) –
 competition among all threads in system
Pthread Scheduling
• API allows specifying either PCS or
  SCS during thread creation
  – PTHREAD SCOPE PROCESS schedules
    threads using PCS scheduling
  – PTHREAD SCOPE SYSTEM schedules
    threads using SCS scheduling.
Pthread Scheduling API
#include <pthread.h>
#include <stdio.h>
#define NUM THREADS 5
int main(int argc, char *argv[])
{
   int i;
  pthread t tid[NUM THREADS];
  pthread attr t attr;
  /* get the default attributes */
  pthread attr init(&attr);
  /* set the scheduling algorithm to PROCESS or
  SYSTEM */
  pthread attr setscope(&attr, PTHREAD SCOPE
  SYSTEM);
  /* set the scheduling policy - FIFO, RT, or
  OTHER */
  pthread attr setschedpolicy(&attr, SCHED OTHER);
  /* create the threads */
  for (i = 0; i < NUM THREADS; i++)
Pthread Scheduling API
    /* now join on each thread */
    for (i = 0; i < NUM THREADS; i++)
       pthread join(tid[i], NULL);
}
  /* Each thread will begin control in
   this function */
void *runner(void *param)
{
   printf("I am a threadn");
   pthread exit(0);
}
Multiple-Processor Scheduling
• CPU scheduling more complex when multiple CPUs are
  available
• Homogeneous processors within a multiprocessor
• Asymmetric multiprocessing – only one processor accesses
  the system data structures, alleviating the need for data sharing
• Symmetric multiprocessing (SMP) – each processor is self-
  scheduling, all processes in common ready queue, or each has
  its own private queue of ready processes
• Processor affinity – process has affinity for processor on
  which it is currently running
    – soft affinity
    – hard affinity
Thread Libraries
• Thread library provides programmer with
  API for creating and managing threads
• Two primary ways of implementing
  – Library entirely in user space
  – Kernel-level library supported by the OS
Pthreads
• May be provided either as user-level or
  kernel-level
• A POSIX standard (IEEE 1003.1c) API for
  thread creation and synchronization
• API specifies behavior of the thread library,
  implementation is up to development of the
  library
• Common in UNIX operating systems
  (Solaris, Linux, Mac OS X)
Threading Issues
• Semantics of fork() and exec() system calls
• Thread cancellation of target thread
    – Asynchronous or deferred
•   Signal handling
•   Thread pools
•   Thread-specific data
•   Scheduler activations
Thread Cancellation
• Terminating a thread before it has finished
• Two general approaches:
  – Asynchronous cancellation terminates the
    target thread immediately
  – Deferred cancellation allows the target thread to
    periodically check if it should be cancelled
Linux Threads
Linux refers to them as tasks rather than threads

Thread creation is done through clone() system call

clone() allows a child task to share the address space of the parent task (process)
Windows XP Threads
Local Procedure Calls in Windows   XP
Windows XP Threads
• Implements the one-to-one mapping, kernel-level
• Each thread contains
   – A thread id
   – Register set
   – Separate user and kernel stacks
   – Private data storage area
• The register set, stacks, and private storage area are
  known as the context of the threads
• The primary data structures of a thread include:
   – ETHREAD (executive thread block)
   – KTHREAD (kernel thread block)
   – TEB (thread environment block)
Alternating Sequence of CPU And
            I/O Bursts
Windows XP Priorities
Linux Scheduling
• Constant order O(1) scheduling time
• Two priority ranges: time-sharing and
  real-time
• Real-time range from 0 to 99 and
  nice value from 100 to 140
• (figure 5.15)
Examples of IPC Systems – Windows XP
• Message-passing centric via local procedure call (LPC) facility
  – Only works between processes on the same system
  – Uses ports (like mailboxes) to establish and maintain
    communication channels
  – Communication works as follows:
     • The client opens a handle to the subsystem’s connection
       port object
     • The client sends a connection request
     • The server creates two private communication ports and
       returns the handle to one of them to the client
     • The client and server use the corresponding port handle
       to send messages or callbacks and to listen for replies
Priorities and Time-slice length

Contenu connexe

Tendances

Tendances (20)

Os rtos.ppt
Os rtos.pptOs rtos.ppt
Os rtos.ppt
 
Vxworks
VxworksVxworks
Vxworks
 
Real time operating system
Real time operating systemReal time operating system
Real time operating system
 
Real-Time Operating Systems
Real-Time Operating SystemsReal-Time Operating Systems
Real-Time Operating Systems
 
Unit 4 Real Time Operating System
Unit 4 Real Time Operating SystemUnit 4 Real Time Operating System
Unit 4 Real Time Operating System
 
Chapter 19 - Real Time Systems
Chapter 19 - Real Time SystemsChapter 19 - Real Time Systems
Chapter 19 - Real Time Systems
 
Cs8493 unit 4
Cs8493 unit 4Cs8493 unit 4
Cs8493 unit 4
 
Os unit 3 , process management
Os unit 3 , process managementOs unit 3 , process management
Os unit 3 , process management
 
Real Time Operating System
Real Time Operating SystemReal Time Operating System
Real Time Operating System
 
REAL TIME OPERATING SYSTEM PART 1
REAL TIME OPERATING SYSTEM PART 1REAL TIME OPERATING SYSTEM PART 1
REAL TIME OPERATING SYSTEM PART 1
 
Real Time Operating Systems
Real Time Operating SystemsReal Time Operating Systems
Real Time Operating Systems
 
Process management in os
Process management in osProcess management in os
Process management in os
 
Rtos ss
Rtos ssRtos ss
Rtos ss
 
Process management os concept
Process management os conceptProcess management os concept
Process management os concept
 
OS - Process Concepts
OS - Process ConceptsOS - Process Concepts
OS - Process Concepts
 
RTOS Basic Concepts
RTOS Basic ConceptsRTOS Basic Concepts
RTOS Basic Concepts
 
RTOS on ARM cortex-M platform -draft
RTOS on ARM cortex-M platform -draftRTOS on ARM cortex-M platform -draft
RTOS on ARM cortex-M platform -draft
 
Rtos princples adn case study
Rtos princples adn case studyRtos princples adn case study
Rtos princples adn case study
 
Rtos part2
Rtos part2Rtos part2
Rtos part2
 
Operating System-Concepts of Process
Operating System-Concepts of ProcessOperating System-Concepts of Process
Operating System-Concepts of Process
 

En vedette

RTOS MICRO CONTROLLER OPERATING SYSTEM-2
RTOS MICRO CONTROLLER OPERATING SYSTEM-2RTOS MICRO CONTROLLER OPERATING SYSTEM-2
RTOS MICRO CONTROLLER OPERATING SYSTEM-2JOLLUSUDARSHANREDDY
 
S3 Individual Presentation - Washing Machine
S3 Individual Presentation - Washing MachineS3 Individual Presentation - Washing Machine
S3 Individual Presentation - Washing Machineno suhaila
 
CASE STUDY OF DIGITAL CAMERA HARDWARE AND SOFT WARE ARCHITECTURECASE STUDY OF...
CASE STUDY OF DIGITAL CAMERAHARDWARE AND SOFT WAREARCHITECTURECASE STUDY OF...CASE STUDY OF DIGITAL CAMERAHARDWARE AND SOFT WAREARCHITECTURECASE STUDY OF...
CASE STUDY OF DIGITAL CAMERA HARDWARE AND SOFT WARE ARCHITECTURECASE STUDY OF...JOLLUSUDARSHANREDDY
 
Microcontroller in automobile and applications
Microcontroller in automobile and applicationsMicrocontroller in automobile and applications
Microcontroller in automobile and applicationsKartik Kalpande Patil
 
Microprocessor in washing machine
Microprocessor in washing machineMicroprocessor in washing machine
Microprocessor in washing machineSandeep Kamath
 
Using 8051 microcontroller based washing machine control ppt
Using 8051 microcontroller based washing machine control pptUsing 8051 microcontroller based washing machine control ppt
Using 8051 microcontroller based washing machine control pptSangeeth Sb
 
UNIT-I-RTOS and Concepts
UNIT-I-RTOS and ConceptsUNIT-I-RTOS and Concepts
UNIT-I-RTOS and ConceptsDr.YNM
 
Applications of 8051 microcontrollers
Applications of 8051 microcontrollersApplications of 8051 microcontrollers
Applications of 8051 microcontrollersDr.YNM
 

En vedette (15)

Os2
Os2Os2
Os2
 
Vx works RTOS
Vx works RTOSVx works RTOS
Vx works RTOS
 
RT linux
RT linuxRT linux
RT linux
 
OS/2 Architecture
OS/2 ArchitectureOS/2 Architecture
OS/2 Architecture
 
Embedded two mark question
Embedded two mark questionEmbedded two mark question
Embedded two mark question
 
RTOS MICRO CONTROLLER OPERATING SYSTEM-2
RTOS MICRO CONTROLLER OPERATING SYSTEM-2RTOS MICRO CONTROLLER OPERATING SYSTEM-2
RTOS MICRO CONTROLLER OPERATING SYSTEM-2
 
S3 Individual Presentation - Washing Machine
S3 Individual Presentation - Washing MachineS3 Individual Presentation - Washing Machine
S3 Individual Presentation - Washing Machine
 
CASE STUDY OF DIGITAL CAMERA HARDWARE AND SOFT WARE ARCHITECTURECASE STUDY OF...
CASE STUDY OF DIGITAL CAMERAHARDWARE AND SOFT WAREARCHITECTURECASE STUDY OF...CASE STUDY OF DIGITAL CAMERAHARDWARE AND SOFT WAREARCHITECTURECASE STUDY OF...
CASE STUDY OF DIGITAL CAMERA HARDWARE AND SOFT WARE ARCHITECTURECASE STUDY OF...
 
Microcontroller in automobile and applications
Microcontroller in automobile and applicationsMicrocontroller in automobile and applications
Microcontroller in automobile and applications
 
Microprocessor in washing machine
Microprocessor in washing machineMicroprocessor in washing machine
Microprocessor in washing machine
 
Rtos Concepts
Rtos ConceptsRtos Concepts
Rtos Concepts
 
Using 8051 microcontroller based washing machine control ppt
Using 8051 microcontroller based washing machine control pptUsing 8051 microcontroller based washing machine control ppt
Using 8051 microcontroller based washing machine control ppt
 
UNIT-I-RTOS and Concepts
UNIT-I-RTOS and ConceptsUNIT-I-RTOS and Concepts
UNIT-I-RTOS and Concepts
 
Applications of 8051 microcontrollers
Applications of 8051 microcontrollersApplications of 8051 microcontrollers
Applications of 8051 microcontrollers
 
Case study of digital camera
Case study of digital cameraCase study of digital camera
Case study of digital camera
 

Similaire à Os2 (20)

OS Process Chapter 3.pdf
OS Process Chapter 3.pdfOS Process Chapter 3.pdf
OS Process Chapter 3.pdf
 
ch5_CPU Scheduling_part1.pdf
ch5_CPU Scheduling_part1.pdfch5_CPU Scheduling_part1.pdf
ch5_CPU Scheduling_part1.pdf
 
Ch05
Ch05Ch05
Ch05
 
cpu sechduling
cpu sechduling cpu sechduling
cpu sechduling
 
OS Process and Thread Concepts
OS Process and Thread ConceptsOS Process and Thread Concepts
OS Process and Thread Concepts
 
Ch6 cpu scheduling
Ch6   cpu schedulingCh6   cpu scheduling
Ch6 cpu scheduling
 
Ch6
Ch6Ch6
Ch6
 
Operating System 5
Operating System 5Operating System 5
Operating System 5
 
ch_scheduling (1).ppt
ch_scheduling (1).pptch_scheduling (1).ppt
ch_scheduling (1).ppt
 
CPU Scheduling Lecture 5 - 6.pptx
CPU Scheduling Lecture 5 - 6.pptxCPU Scheduling Lecture 5 - 6.pptx
CPU Scheduling Lecture 5 - 6.pptx
 
Ch5
Ch5Ch5
Ch5
 
Window scheduling algorithm
Window scheduling algorithmWindow scheduling algorithm
Window scheduling algorithm
 
Cpu_sheduling.pptx
Cpu_sheduling.pptxCpu_sheduling.pptx
Cpu_sheduling.pptx
 
5 Process Scheduling
5 Process Scheduling5 Process Scheduling
5 Process Scheduling
 
Ch05 cpu-scheduling
Ch05 cpu-schedulingCh05 cpu-scheduling
Ch05 cpu-scheduling
 
OSCh6
OSCh6OSCh6
OSCh6
 
OS_Ch6
OS_Ch6OS_Ch6
OS_Ch6
 
Process Scheduling
Process SchedulingProcess Scheduling
Process Scheduling
 
CH06.pdf
CH06.pdfCH06.pdf
CH06.pdf
 
Operating System Scheduling
Operating System SchedulingOperating System Scheduling
Operating System Scheduling
 

Plus de gopal10scs185 (20)

Os5
Os5Os5
Os5
 
Os4
Os4Os4
Os4
 
Os1
Os1Os1
Os1
 
Os8
Os8Os8
Os8
 
Os8
Os8Os8
Os8
 
Os7
Os7Os7
Os7
 
Os6
Os6Os6
Os6
 
Os4
Os4Os4
Os4
 
Os3
Os3Os3
Os3
 
Unit4 desiging classes
Unit4 desiging classesUnit4 desiging classes
Unit4 desiging classes
 
Unit three identifying actors
Unit three  identifying actorsUnit three  identifying actors
Unit three identifying actors
 
Unit 5 testing
Unit 5 testingUnit 5 testing
Unit 5 testing
 
Unit 5
Unit 5Unit 5
Unit 5
 
Unit 5 usability and satisfaction test
Unit 5 usability and satisfaction testUnit 5 usability and satisfaction test
Unit 5 usability and satisfaction test
 
Unit 5 testing -software quality assurance
Unit 5  testing -software quality assuranceUnit 5  testing -software quality assurance
Unit 5 testing -software quality assurance
 
Unit 4
Unit 4Unit 4
Unit 4
 
Unit 4 designing classes
Unit 4  designing classesUnit 4  designing classes
Unit 4 designing classes
 
Unit 3 object analysis-classification
Unit 3 object analysis-classificationUnit 3 object analysis-classification
Unit 3 object analysis-classification
 
Unit 3 attributes, methods, relationships
Unit 3 attributes, methods, relationshipsUnit 3 attributes, methods, relationships
Unit 3 attributes, methods, relationships
 
Unit 3
Unit 3Unit 3
Unit 3
 

Dernier

A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 

Dernier (20)

A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 

Os2

  • 1. OPERATING SYTEMS B.TECH II YR (TERM 08-09) UNIT 2 PPT SLIDES TEXT BOOKS: Operating System Concepts- Abraham Silberchatz, Peter B. Galvin, Greg Gagne 7th Edition, John Wiley Operating systems- A Concept based Approach- D.M.Dhamdhere, 2nd Edition, TMH. No. of slides: 52
  • 2. INDEX UNIT 2 PPT SLIDES S.NO. TOPIC LECTURE NO. PPTSLIDES 1. Process concepts threads L9 L9.1 to L9.10 2. scheduling-criteria alg L10 L10.1 to L10.7 4. scheduling-criteria alg L11 L11.1 to L11.7 5. Algorithms evaluation L12 L12.1 to L12.6 5. Thread scheduling L13 L13.1 to L13.11 6. Case studies UNIX,LINUX L14 L14.1 to L14.4 7. Windows L15 L15.1 to L15.2 8. REVISION L16
  • 3. Process Concept • An operating system executes a variety of programs: – Batch system – jobs – Time-shared systems – user programs or tasks • Textbook uses the terms job and process almost interchangeably • Process – a program in execution; process execution must progress in sequential fashion • A process includes: – program counter – stack – data section
  • 4. Process State • As a process executes, it changes state – new: The process is being created – running: Instructions are being executed – waiting: The process is waiting for some event to occur – ready: The process is waiting to be assigned to a processor – terminated: The process has finished execution
  • 6. Process Control Block (PCB) Information associated with each process • Process state • Program counter • CPU registers • CPU scheduling information • Memory-management information • Accounting information • I/O status information
  • 8. CPU Switch From Process to Process
  • 9. Process Scheduling Queues • Job queue – set of all processes in the system • Ready queue – set of all processes residing in main memory, ready and waiting to execute • Device queues – set of processes waiting for an I/O device • Processes migrate among the various queues
  • 10. Ready Queue And Various I/O Device Queues
  • 12. Schedulers • Long-term scheduler (or job scheduler) – selects which processes should be brought into the ready queue • Short-term scheduler (or CPU scheduler) – selects which process should be executed next and allocates CPU
  • 13. Producer-Consumer Problem • Paradigm for cooperating processes, producer process produces information that is consumed by a consumer process – unbounded-buffer places no practical limit on the size of the buffer – bounded-buffer assumes that there is a fixed buffer size
  • 14. Bounded-Buffer – Shared-Memory Solution • Shared data #define BUFFER_SIZE 10 typedef struct { ... } item; item buffer[BUFFER_SIZE]; int in = 0; int out = 0; • Solution is correct, but can only use BUFFER_SIZE-1 elements
  • 15. Bounded-Buffer – Producer while (true) { /* Produce an item */ while (((in = (in + 1) % BUFFER SIZE count) == out) ; /* do nothing -- no free buffers */ buffer[in] = item; in = (in + 1) % BUFFER SIZE;
  • 16. Bounded Buffer – Consumer while (true) { while (in == out) ; // do nothing -- nothing to consume // remove an item from the buffer item = buffer[out]; out = (out + 1) % BUFFER SIZE;
  • 17. Scheduling Criteria • CPU utilization – keep the CPU as busy as possible • Throughput – # of processes that complete their execution per time unit • Turnaround time – amount of time to execute a particular process • Waiting time – amount of time a process has been waiting in the ready queue • Response time – amount of time it takes from when a request was submitted until the first response is produced, not output (for time-sharing environment)
  • 18. Scheduling Algorithm Optimization Criteria • Max CPU utilization • Max throughput • Min turnaround time • Min waiting time • Min response time
  • 19. First-Come, First-Served (FCFS) Scheduling ProcessBurst Time P1 24 P2 3 P3 3 • Suppose that the processes arrive in the order: P1 , P2 , P3 The Gantt Chart for the schedule is: P1 P2 P3 0 24 27 30
  • 20. FCFS Scheduling (Cont) Suppose that the processes arrive in the order P2 , P3 , P 1 • The Gantt chart for the schedule is: Waiting time for P1 = 6; P2 = 0; P3 = 3 • Average waiting time: (6 + 0 + 3)/3 = 3 • Much better than previous case • Convoy effect short process behind long process P2 P3 P1 0 3 6 30
  • 21. Shortest-Job-First (SJF) Scheduling • Associate with each process the length of its next CPU burst. Use these lengths to schedule the process with the shortest time • SJF is optimal – gives minimum average waiting time for a given set of processes – The difficulty is knowing the length of the next CPU request
  • 22. Determining Length of Next CPU Burst • Can only estimate the length • Can be done by using the length of previous CPU bursts, using exponential averaging τ n = 1 = α t n + ( 1 − α )τ n . 1. t n = actual length of n th CPU burst 2. τ n +1 = predicted value for the next CPU burst 3. α , 0 ≤ α ≤ 1 4. Define :
  • 23. Examples of Exponential Averaging ∀ α =0 τn+1 = τn – Recent history does not count ∀ α =1 – τn+1 = α tn – Only the actual last CPU burst counts • If we expand the formula, we get: τn+1 = α tn+(1 - α)α tn -1 + … +(1 - α )j α tn -j + … +(1 - α )n +1 τ0 • Since both α and (1 - α) are less than or equal
  • 24. Priority Scheduling • A priority number (integer) is associated with each process • The CPU is allocated to the process with the highest priority (smallest integer ≡ highest priority) – Preemptive – nonpreemptive • SJF is a priority scheduling where priority is the predicted next CPU burst time • Problem ≡ Starvation – low priority processes may never execute • Solution ≡ Aging – as time progresses increase the priority of the process
  • 25. Round Robin (RR) • Each process gets a small unit of CPU time (time quantum), usually 10-100 milliseconds. After this time has elapsed, the process is preempted and added to the end of the ready queue. • If there are n processes in the ready queue and the time quantum is q, then each process gets 1/n of the CPU time in chunks of at most q time units at once. No process waits more than (n-1)q time units. • Performance – q large ⇒ FIFO – q small ⇒ q must be large with respect to context switch, otherwise overhead is too high Process Burst Time P1 24 P2 3 P1 P2 P3 P1 P1 P1 P1 P1 P3 3 0 4 7 10 14 18 22 26 30 The Gantt chart is: Typically, higher average turnaround than SJF, but better response
  • 26. Time Quantum and Context Switch Time
  • 27. Multilevel Queue Scheduling Multilevel Feedback Queues NUMA and CPU Scheduling
  • 28. Algorithm Evaluation • Deterministic modeling – takes a particular predetermined workload and defines the performance of each algorithm for that workload • Queueing models • Implementation
  • 29. Evaluation of CPU schedulers by Simulation
  • 31. Time-Slicing Since the JVM Doesn’t Ensure Time- Slicing, the yield() Method May Be Used: while (true) { // perform CPU-intensive task ... Thread.yield(); }
  • 32. Thread Priorities Priority Comment Thread.MIN_PRIORITY Minimum Thread Priority Thread.MAX_PRIORITY Maximum Thread Priority Thread.NORM_PRIORITY Default Thread Priority Priorities May Be Set Using setPriority() method: setPriority(Thread.NORM_PRIORITY + 2);
  • 34. User Threads • Thread management done by user-level threads library • Three primary thread libraries: – POSIX Pthreads – Win32 threads Kernel – Java threads Threads • Supported by the Kernel • Examples – Windows XP/2000 – Solaris – Linux – Tru64 UNIX – Mac OS X
  • 35. Thread Scheduling • Distinction between user-level and kernel-level threads • Many-to-one and many-to-many models, thread library schedules user-level threads to run on LWP – Known as process-contention scope (PCS) since scheduling competition is within the process Kernel thread scheduled onto available CPU is system-contention scope (SCS) – competition among all threads in system
  • 36. Pthread Scheduling • API allows specifying either PCS or SCS during thread creation – PTHREAD SCOPE PROCESS schedules threads using PCS scheduling – PTHREAD SCOPE SYSTEM schedules threads using SCS scheduling.
  • 37. Pthread Scheduling API #include <pthread.h> #include <stdio.h> #define NUM THREADS 5 int main(int argc, char *argv[]) { int i; pthread t tid[NUM THREADS]; pthread attr t attr; /* get the default attributes */ pthread attr init(&attr); /* set the scheduling algorithm to PROCESS or SYSTEM */ pthread attr setscope(&attr, PTHREAD SCOPE SYSTEM); /* set the scheduling policy - FIFO, RT, or OTHER */ pthread attr setschedpolicy(&attr, SCHED OTHER); /* create the threads */ for (i = 0; i < NUM THREADS; i++)
  • 38. Pthread Scheduling API /* now join on each thread */ for (i = 0; i < NUM THREADS; i++) pthread join(tid[i], NULL); } /* Each thread will begin control in this function */ void *runner(void *param) { printf("I am a threadn"); pthread exit(0); }
  • 39. Multiple-Processor Scheduling • CPU scheduling more complex when multiple CPUs are available • Homogeneous processors within a multiprocessor • Asymmetric multiprocessing – only one processor accesses the system data structures, alleviating the need for data sharing • Symmetric multiprocessing (SMP) – each processor is self- scheduling, all processes in common ready queue, or each has its own private queue of ready processes • Processor affinity – process has affinity for processor on which it is currently running – soft affinity – hard affinity
  • 40. Thread Libraries • Thread library provides programmer with API for creating and managing threads • Two primary ways of implementing – Library entirely in user space – Kernel-level library supported by the OS
  • 41. Pthreads • May be provided either as user-level or kernel-level • A POSIX standard (IEEE 1003.1c) API for thread creation and synchronization • API specifies behavior of the thread library, implementation is up to development of the library • Common in UNIX operating systems (Solaris, Linux, Mac OS X)
  • 42. Threading Issues • Semantics of fork() and exec() system calls • Thread cancellation of target thread – Asynchronous or deferred • Signal handling • Thread pools • Thread-specific data • Scheduler activations
  • 43. Thread Cancellation • Terminating a thread before it has finished • Two general approaches: – Asynchronous cancellation terminates the target thread immediately – Deferred cancellation allows the target thread to periodically check if it should be cancelled
  • 44. Linux Threads Linux refers to them as tasks rather than threads Thread creation is done through clone() system call clone() allows a child task to share the address space of the parent task (process)
  • 46. Local Procedure Calls in Windows XP
  • 47. Windows XP Threads • Implements the one-to-one mapping, kernel-level • Each thread contains – A thread id – Register set – Separate user and kernel stacks – Private data storage area • The register set, stacks, and private storage area are known as the context of the threads • The primary data structures of a thread include: – ETHREAD (executive thread block) – KTHREAD (kernel thread block) – TEB (thread environment block)
  • 48. Alternating Sequence of CPU And I/O Bursts
  • 50. Linux Scheduling • Constant order O(1) scheduling time • Two priority ranges: time-sharing and real-time • Real-time range from 0 to 99 and nice value from 100 to 140 • (figure 5.15)
  • 51. Examples of IPC Systems – Windows XP • Message-passing centric via local procedure call (LPC) facility – Only works between processes on the same system – Uses ports (like mailboxes) to establish and maintain communication channels – Communication works as follows: • The client opens a handle to the subsystem’s connection port object • The client sends a connection request • The server creates two private communication ports and returns the handle to one of them to the client • The client and server use the corresponding port handle to send messages or callbacks and to listen for replies