Top Banner
Advanced Operating Systems CIS 720 Lecture 1
26

Advanced Operating Systems CIS 720 Lecture 1. Instructor Dr. Gurdip Singh – 234 Nichols Hall – [email protected] [email protected].

Jan 11, 2016

Download

Documents

Sibyl Evans
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Advanced Operating Systems CIS 720 Lecture 1. Instructor Dr. Gurdip Singh – 234 Nichols Hall – gurdip@ksu.edu gurdip@ksu.edu.

Advanced Operating SystemsCIS 720

Lecture 1

Page 2: Advanced Operating Systems CIS 720 Lecture 1. Instructor Dr. Gurdip Singh – 234 Nichols Hall – gurdip@ksu.edu gurdip@ksu.edu.

Instructor

• Dr. Gurdip Singh– 234 Nichols Hall– [email protected]

Page 3: Advanced Operating Systems CIS 720 Lecture 1. Instructor Dr. Gurdip Singh – 234 Nichols Hall – gurdip@ksu.edu gurdip@ksu.edu.

Course Web-site

www.cis.ksu.edu/~singh/CIS720/F13/cis720.html

Page 4: Advanced Operating Systems CIS 720 Lecture 1. Instructor Dr. Gurdip Singh – 234 Nichols Hall – gurdip@ksu.edu gurdip@ksu.edu.

Overall Goals

• Concurrent programming– Multi-threaded programming– Parallel Programming

• Distributed Operating Systems– Message passing systems– Replication and Fault Tolerance– Distributed shared memory– Concurrency control

Page 5: Advanced Operating Systems CIS 720 Lecture 1. Instructor Dr. Gurdip Singh – 234 Nichols Hall – gurdip@ksu.edu gurdip@ksu.edu.

Outline

• Concurrent programming introduction• Structured design of concurrent programs

– Design methodologies• Synchronization primitives:

– Semaphore, locks, monitors• Correctness proofs• Message passing programs• Replication• Distributed Shared Data• Concurrency Control

Page 6: Advanced Operating Systems CIS 720 Lecture 1. Instructor Dr. Gurdip Singh – 234 Nichols Hall – gurdip@ksu.edu gurdip@ksu.edu.

Course evaluation

• Homeworks 10%• Programming assignments 25-30%• Midterm 25-30%• Final 35-40%

Page 7: Advanced Operating Systems CIS 720 Lecture 1. Instructor Dr. Gurdip Singh – 234 Nichols Hall – gurdip@ksu.edu gurdip@ksu.edu.

Course tools and Pre-req

• Programming language: Java• Recommended (not required) book:

Foundations of Multi-threaded, Parallel and Distributed Programming, Gregory Andrews

• Undergraduate Operating Systems course• Multi-threaded programming

Page 8: Advanced Operating Systems CIS 720 Lecture 1. Instructor Dr. Gurdip Singh – 234 Nichols Hall – gurdip@ksu.edu gurdip@ksu.edu.

Related Courses

• CIS625: Parallel Programming• CIS725: Advanced Computer Networks• CIS722: Operating Systems Practices• CIS726: WWW Technologies• CIS825: Topics in Distributed Computing

Page 9: Advanced Operating Systems CIS 720 Lecture 1. Instructor Dr. Gurdip Singh – 234 Nichols Hall – gurdip@ksu.edu gurdip@ksu.edu.

Sequential Program/Systems

• A system is sequential if no more than one control point can be serviced at a time.

• A program is sequential if no more than one control point can be enabled at a time.

Page 10: Advanced Operating Systems CIS 720 Lecture 1. Instructor Dr. Gurdip Singh – 234 Nichols Hall – gurdip@ksu.edu gurdip@ksu.edu.

Concurrent program/system

• A program is concurrent if multiple control points can be enabled at the same time.

• A system is concurrent if multiple control points can be serviced at the same time.

Page 11: Advanced Operating Systems CIS 720 Lecture 1. Instructor Dr. Gurdip Singh – 234 Nichols Hall – gurdip@ksu.edu gurdip@ksu.edu.

Why concurrent programming

• Exploiting parallelism in an application– Matrix multiplication– Finding a maximum in an array

• Better architecture• Inherently concurrent applications• Availability of concurrent platforms

Page 12: Advanced Operating Systems CIS 720 Lecture 1. Instructor Dr. Gurdip Singh – 234 Nichols Hall – gurdip@ksu.edu gurdip@ksu.edu.

Example system• Consider a control system:

1. Brake Sensor: When it detects a brake action, it must actuate the brakes within 20ms. The execution time is 5ms.

2. AC Button: It must start the AC within 4s after it detects the button press. The execution time is 500ms.

3. Cruise Control button. It must activate the cruise control within 2s . The execution time is 100ms.

Page 13: Advanced Operating Systems CIS 720 Lecture 1. Instructor Dr. Gurdip Singh – 234 Nichols Hall – gurdip@ksu.edu gurdip@ksu.edu.

Control-Loop Systemmain( ) {

….initialize….

while (1) {   if (flagBrake) {activateBrakes( );   flagBrake = false;}   if (flagAC) {activateAC( ); flagAC = false;}   if (flagCruise) {activateCruise( ); flagCruise = false;} }}

Each interrupt handler simply sets the corresponding flag

Page 14: Advanced Operating Systems CIS 720 Lecture 1. Instructor Dr. Gurdip Singh – 234 Nichols Hall – gurdip@ksu.edu gurdip@ksu.edu.

Control-Loop System• Pros:

– It’s a simple sequential code– Debugging is easy; Developed systems are reliable.

• Cons:– It is difficult to satisfy real-time requirements.

• For example, what will happen if a brake action is detected while the control loop is executing ActivateCruise( ), which takes the maximum of 100ms ?

Page 15: Advanced Operating Systems CIS 720 Lecture 1. Instructor Dr. Gurdip Singh – 234 Nichols Hall – gurdip@ksu.edu gurdip@ksu.edu.

Event-Triggered System• The system assigns a thread to each task• For each sensor interrupt, the system dispatches the thread assigned to

the corresponding task– Brake controller: create a thread that executes BrakeFunction( )

• The thread priorities should be (1) the Brake control task (highest), (2) the Cruise control task, and (3) the AC control task (lowest)

BrakeFunction( ) { init( ); while (…) { : activateBrake( ); : }}

AC_Control( ) { init( ); while (…) { : activateAC( ); : }}

Cruise_Control( ) { init( ); while (…) { : activateCruise( ); : }}

Page 16: Advanced Operating Systems CIS 720 Lecture 1. Instructor Dr. Gurdip Singh – 234 Nichols Hall – gurdip@ksu.edu gurdip@ksu.edu.

Concurrent Programs• Advantages:

– can increase CPU utilization– can provide fair service to many clients– can improve response time– allow programmers to focus only on sequential execution of

each thread

• Disadvantages:– synchronization code is required to coordinate the execution of

the multiple threads– Scheduling

Page 17: Advanced Operating Systems CIS 720 Lecture 1. Instructor Dr. Gurdip Singh – 234 Nichols Hall – gurdip@ksu.edu gurdip@ksu.edu.

Operating System

• Process/thread creation • Program execution: Scheduling• Access to I/O devices• Memory management• Accounting :

Page 18: Advanced Operating Systems CIS 720 Lecture 1. Instructor Dr. Gurdip Singh – 234 Nichols Hall – gurdip@ksu.edu gurdip@ksu.edu.

• All the runnable software on a computer, including the OS, is organized into a number of sequential processes (or processes in short)

• Process: a unit of work scheduled by OS, consisting of 1. program's data and stack (and the memory areas)2. program counter, stack pointer, and other CPU registers3. all other information necessary to run the program:

process id, priority, accounting information, memory information, open files, process state, etc.

4. executable code (and the memory area)

Processes

stored in process control blocks (PCBs)

Page 19: Advanced Operating Systems CIS 720 Lecture 1. Instructor Dr. Gurdip Singh – 234 Nichols Hall – gurdip@ksu.edu gurdip@ksu.edu.

Process States• New – process is being created.• Running – instructions are being executed.• Waiting – blocked waiting for an external event to occur; e.g., message

arrival.• Ready – ready to run on a processor.• Terminated – finished, awaiting garbage collection.

New

Ready

Running

Waiting

Terminated

Page 20: Advanced Operating Systems CIS 720 Lecture 1. Instructor Dr. Gurdip Singh – 234 Nichols Hall – gurdip@ksu.edu gurdip@ksu.edu.

Multiprogramming

• In a multiprogramming system, the CPU switches from program to program, giving the users the illusion of parallelism (pseudo parallelism)

Page 21: Advanced Operating Systems CIS 720 Lecture 1. Instructor Dr. Gurdip Singh – 234 Nichols Hall – gurdip@ksu.edu gurdip@ksu.edu.

Implementing Processes• When a context switch occurs between processes P0 and P1, the

current state of running process P0 is saved in the PCB for P0, and the state of ready process P1 is restored from the PCB for P1.

Page 22: Advanced Operating Systems CIS 720 Lecture 1. Instructor Dr. Gurdip Singh – 234 Nichols Hall – gurdip@ksu.edu gurdip@ksu.edu.

Process Scheduling• In a general operating system, a context switch occurs after each time

quantum has expired; e.g., every 20 msec.• Non-preemptive scheduling

Page 23: Advanced Operating Systems CIS 720 Lecture 1. Instructor Dr. Gurdip Singh – 234 Nichols Hall – gurdip@ksu.edu gurdip@ksu.edu.

Task Period Deadline Run-Time

Ti Di Ci

--------------------------------------------------------------------- A 2 2 1 B 5 5 1

Example

A

B

20 4 5 10 15(thanks to M. Neilsen)

Page 24: Advanced Operating Systems CIS 720 Lecture 1. Instructor Dr. Gurdip Singh – 234 Nichols Hall – gurdip@ksu.edu gurdip@ksu.edu.

Task Period Deadline Run-Time

Ti Di Ci

--------------------------------------------------------------------- A 2 2 1 B 5 5 2

Example

A

B

20 4 5 10 15

Page 25: Advanced Operating Systems CIS 720 Lecture 1. Instructor Dr. Gurdip Singh – 234 Nichols Hall – gurdip@ksu.edu gurdip@ksu.edu.

Process Scheduler• The process scheduler determines which process to schedule (switch to)

next.

• Types of schedulers:– preemptive– non-preemptive

• Scheduling Criteria:– CPU Utilization– Throughput - completions/time period– Turnaround time - total execution time– Waiting time - time spent in ready queue– Response time - time until first response– No missed deadlines - in a hard real-time system this is the most

important criteria!

Page 26: Advanced Operating Systems CIS 720 Lecture 1. Instructor Dr. Gurdip Singh – 234 Nichols Hall – gurdip@ksu.edu gurdip@ksu.edu.

Task Period Deadline Run-Time τi Ti Di Ci

--------------------------------------------------------------------- A 2 2 1 B 5 5 2

Example

A

B

20 4 5 10 15

(High Priority)

(Low Priority)