REVIEW OF COMMONLY USED DATA STRUCTURES IN OS

Similar documents
Processes. Sanzheng Qiao. December, Department of Computing and Software

Chap 4, 5: Process. Dongkun Shin, SKKU

Process a program in execution; process execution must progress in sequential fashion. Operating Systems

Processes. Process Management Chapter 3. When does a process gets created? When does a process gets terminated?

PROCESS CONTROL BLOCK TWO-STATE MODEL (CONT D)

Process Concepts 8/21/2014. CS341: Operating System. Scheduling: Theoretical Analysis

CSC 539: Operating Systems Structure and Design. Spring 2006

THE PROCESS ABSTRACTION. CS124 Operating Systems Winter , Lecture 7

Announcements Processes: Part II. Operating Systems. Autumn CS4023

Process Description and Control. Chapter 3

Processes. OS Structure. OS Structure. Modes of Execution. Typical Functions of an OS Kernel. Non-Kernel OS. COMP755 Advanced Operating Systems

CPSC 341 OS & Networks. Processes. Dr. Yingwu Zhu

Getting to know you. Anatomy of a Process. Processes. Of Programs and Processes

CHAPTER 2: PROCESS MANAGEMENT

W4118 Operating Systems. Junfeng Yang

Chapter 3: Processes. Operating System Concepts 9 th Edit9on

1 PROCESSES PROCESS CONCEPT The Process Process State Process Control Block 5

CIS233J Java Programming II. Threads

Processes. CS 416: Operating Systems Design, Spring 2011 Department of Computer Science Rutgers University

CSCE 313: Intro to Computer Systems

CSCE 313 Introduction to Computer Systems. Instructor: Dezhen Song

CS 471 Operating Systems. Yue Cheng. George Mason University Fall 2017

Processes. Process Concept

ECE 7650 Scalable and Secure Internet Services and Architecture ---- A Systems Perspective. Part I: Operating system overview: Processes and threads

Chapter 3: Process-Concept. Operating System Concepts 8 th Edition,

Processes. CS 475, Spring 2018 Concurrent & Distributed Systems

Lecture 4: Process Management

PROCESS MANAGEMENT. Operating Systems 2015 Spring by Euiseong Seo

Computer Systems II. First Two Major Computer System Evolution Steps

Announcement. Exercise #2 will be out today. Due date is next Monday

Processes and Threads. Processes and Threads. Processes (2) Processes (1)

Part V. Process Management. Sadeghi, Cubaleska RUB Course Operating System Security Memory Management and Protection

Chapter 3: Processes. Operating System Concepts 8th Edition,

Processes and Non-Preemptive Scheduling. Otto J. Anshus

Process Description and Control. Chapter 3

Roadmap. Tevfik Ko!ar. CSC Operating Systems Spring Lecture - III Processes. Louisiana State University. Virtual Machines Processes

Killing Zombies, Working, Sleeping, and Spawning Children

Processes and More. CSCI 315 Operating Systems Design Department of Computer Science

Chapter 3: Processes

CSC Operating Systems Spring Lecture - XII Midterm Review. Tevfik Ko!ar. Louisiana State University. March 4 th, 2008.

Roadmap. Tevfik Ko!ar. CSC Operating Systems Fall Lecture - III Processes. Louisiana State University. Processes. September 1 st, 2009

SMD149 - Operating Systems

Operating Systems Process description and control

Major Requirements of an OS

Processes. CS3026 Operating Systems Lecture 05

Processes. Dr. Yingwu Zhu

Operating System Control Structures

B. V. Patel Institute of Business Management, Computer &Information Technology, UTU

csci3411: Operating Systems

Process Description and Control

Lecture 3: Processes. CMPUT 379, Section A1, Winter 2014 January 13, 15 and 17

Diagram of Process State Process Control Block (PCB)

Processes. Overview. Processes. Process Creation. Process Creation fork() Processes. CPU scheduling. Pål Halvorsen 21/9-2005

Process! Process Creation / Termination! Process Transitions in" the Two-State Process Model! A Two-State Process Model!

Operating Systems CMPSCI 377 Spring Mark Corner University of Massachusetts Amherst

Process Description and Control. Chapter 3

OS Main Goals. 10/24/2013 Operating Systems, Beykent University 1

! The Process Control Block (PCB) " is included in the context,

Introduction to OS Processes in Unix, Linux, and Windows MOS 2.1 Mahmoud El-Gayyar

Process. Heechul Yun. Disclaimer: some slides are adopted from the book authors slides with permission

Processes. Operating System CS 217. Supports virtual machines. Provides services: User Process. User Process. OS Kernel. Hardware

Process. Program Vs. process. During execution, the process may be in one of the following states

Lecture 2 Process Management

Operating Systems & Concurrency: Process Concepts

Processes & Threads. Recap of the Last Class. Microkernel System Architecture. Layered Structure

CS 326: Operating Systems. Process Execution. Lecture 5

Chapter 3 Processes. Process Concept. Process Concept. Process Concept (Cont.) Process Concept (Cont.) Process Concept (Cont.)

Mon Sep 17, 2007 Lecture 3: Process Management

What Is A Process? Process States. Process Concept. Process Control Block (PCB) Process State Transition Diagram 9/6/2013. Process Fundamentals

Chapter 3: Processes. Operating System Concepts 8 th Edition,

Chapter 3: Processes. Operating System Concepts Essentials 2 nd Edition

Today: Process Management. The Big Picture So Far. What's in a Process? Example Process State in Memory

ECE 550D Fundamentals of Computer Systems and Engineering. Fall 2017

Computer Systems Assignment 2: Fork and Threads Package

The Big Picture So Far. Chapter 4: Processes

Unix Processes. What is a Process?

2 Processes. 2 Processes. 2 Processes. 2.1 The Process Model. 2.1 The Process Model PROCESSES OPERATING SYSTEMS

The Big Picture So Far. Today: Process Management

Processes, PCB, Context Switch

Processes. Operating System Concepts 8 th Edition

Operating Systems. Lecture 3- Process Description and Control. Masood Niazi Torshiz

Operating Systems. Figure: Process States. 1 P a g e

OS lpr. www. nfsd gcc emacs ls 1/27/09. Process Management. CS 537 Lecture 3: Processes. Example OS in operation. Why Processes? Simplicity + Speed

Ricardo Rocha. Department of Computer Science Faculty of Sciences University of Porto

OS lpr. www. nfsd gcc emacs ls 9/18/11. Process Management. CS 537 Lecture 4: Processes. The Process. Why Processes? Simplicity + Speed

Reading Assignment 4. n Chapter 4 Threads, due 2/7. 1/31/13 CSE325 - Processes 1

CS370: System Architecture & Software [Fall 2014] Dept. Of Computer Science, Colorado State University

Processes in linux. What s s a process? process? A dynamically executing instance of a program. David Morgan. David Morgan

Creating Threads COMP755

The Process Abstraction. CMPU 334 Operating Systems Jason Waterman

Course: Operating Systems Instructor: M Umair. M Umair

The Kernel Abstraction. Chapter 2 OSPP Part I

Process Description and Control. Major Requirements of an Operating System

Major Requirements of an Operating System Process Description and Control

Templates what and why? Beware copying classes! Templates. A simple example:

IT 540 Operating Systems ECE519 Advanced Operating Systems

Chapter 3: Processes

Processes and Threads

The Big Picture So Far. Chapter 4: Processes

What is a Process. Processes. Programs and Processes. System Classification 3/5/2013. Process: An execution stream and its associated state

Transcription:

REVIEW OF COMMONLY USED DATA STRUCTURES IN OS

NEEDS FOR EFFICIENT DATA STRUCTURE Storage complexity & Computation complexity matter Consider the problem of scheduling tasks according to their priority on CPU New tasks upon arrival, need to be inserted to the queue of pending tasks Every 100ms, find the task of the highest priority May need to update the priority of existing tasks at run time

LINKED LISTS Used in process management, CPU scheduling, file systems A sequence of nodes consisting of <data, pointer(s)> Singly linked list struct list_el { int val; struct list_el * next; }; public class LinkedList<E> Singly linked list in C Linked list in Java

LINKED LISTS (CONT D) Consider a linked list of size n Storage space? Cost of inserting a new element at a position x? Cost of deleting an existing element? Forward traversal? Reverse traversal?

DOUBLY LINKED LIST struct list_el { void *val; struct list_el * prev; struct list_el * next; }; public class LinkedList<E> Singly linked list in C Linked list in Java

DOUBLY-LINKED LISTS (CONT D) Consider a doubly-linked list of size n Storage space? Cost of inserting a new element at a position x? Cost of deleting an existing element? Forward traversal? Reverse traversal?

(MIN-)HEAP Useful in CPU scheduling (e.g., priority queues) The key of parents always no greater than their children Storage space? Find-min Insertion Delete-min 3 5 4 26 25 12 15 29 45 35 31 21 14 Binary minimum heap

(MAX-)HEAP (CONT D) DELETE MIN 3 14 5 4 5 4 26 25 12 15 26 25 12 15 29 45 35 31 21 14 29 45 35 31 21 Find smaller of the two children & swap 5 4 14 5 4 12 26 25 12 15 29 45 35 31 21 26 25 14 15 29 45 35 31 21

B-TREE Used mostly in storage & file systems internal (non-leaf) nodes can be have a variable # of child nodes in some pre-defined range Binary tree B-tree of order 5 Each node has at most 5 children (k-1) keys for k children All leaves at the same level

B-TREE (CONT D) B-tree of n nodes Space complexity? Search Insert Delete Finding 14 Insert 21

HASH TABLE Used in memory management <key, value> pairs Search & storage in O(1), except when collision occurs One solution to hash collision is to use separate chaining

PROCESS MANAGEMENT READINGS: CHAPTER 3-4

OVERVIEW Processes States of a process Operations on processes fork(), exec(), kill (), signal() Cooperating Processes pipes Threads and lightweight processes

PROCESSES A process is a program executing a given sequential computation. An active entity unlike a program Think of the difference between a recipe in a cookbook and the activity of a cook preparing a dish according to the recipe! There are many quasi-synonyms for process: Job (very old programmers still use it) Task Program (strongly deprecated)

PROCESSES AND PROGRAMS (I) Can have one program and many processes When several users execute the same program (text editor, compiler, and so forth) at the same time, each execution of the program constitutes a separate process A program that forks another sequential computation gives birth to a new process.

PROCESSES AND PROGRAMS (II) Can have one process and two or more programs A process that performs an exec() call replaces the program it was executing shell ls

IMPORTANCE OF PROCESSES Processes are the basic entities managed by the operating system OS provides to each process the illusion it has the whole machine for itself Each process has a dedicated address space

THE PROCESS ADDRESS SPACE Set of main memory locations allocated to the process Other processes cannot access them Process cannot access address spaces of other processes A process address space is the playpen or the sandbox of its owner Process address space is contiguous

PROCESS STATES Processes go repeatedly through several stages during their execution Waiting to get into main memory Waiting for the CPU Running Waiting for the completion of a system call

STATE DIAGRAM Running Exit Terminated Get CPU Interrupt System request New Ready Waiting Admit process Completion

PROCESS ARRIVAL New process Starts in NEW state Gets allocated a Process Control Block (PCB) and main memory Is put in the READY state waiting for CPU time

THE READY STATE AKA the ready queue Contains all processes waiting for the CPU Organized as a priority queue Processes leave the priority queue when they get some CPU time Move then to the RUNNING state

THE RUNNING STATE (I) A process in the running state has exclusive use of the CPU until It terminates and goes to the TERMINATED state It does a system call and goes to the WAITING state It is interrupted and returns to the READY state

THE RUNNING STATE (II) Processes are forced to relinquish the CPU and return to the READY state when A higher-priority process arrives in the ready queue and preempts the running process Get out, I m more urgent than you! A timer interrupt indicates that the process has exceeded its time slice of CPU time

THE WAITING STATE (I) Contains all processes waiting for the completion of a system request: I/O operation Any other system call Process is said to be waiting, blocked or even sleeping (UNIX slang)

THE WAITING STATE (II) A system call that does not require callers to wait until its completion is said to be non-blocking Calling processes are immediately returned to the READY state The waiting state is organized as a set of queues One queue per device, OS resource

THE PROCESS CONTROL BLOCK (I) Contains all the information associated with a specific process: Process identification (pid), argument vector,... UNIX pids are unique integers Process state (new, ready, running, ), CPU scheduling information Process priority, processors on which the process can run,..., process state process number program counter registers memory limits list of open files

THE PROCESS CONTROL BLOCK (II) Program counter and other CPU registers including the Program Status Word (PSW), Memory management information Very system specific, Accounting information CPU time used, system time used,... I/O status information (list of opened files, allocated devices,...) process state process number program counter registers memory limits list of open files

THE PROCESS TABLE System-wide table containing Process identification (pid), argument vector,... Process current state Process parents Process priority and other CPU scheduling information A pointer to the executable machine code of a process

SWAPPING Whenever the system is very loaded, we might want to expel from main memory or swap out Low priority processes Processes that have been waiting for a long time for an external event These processes are said to be swapped out or suspended.

HOW IT WORKS Admit process Get CPU Running Interrupt Exit New Ready Waiting Completion Suspended Ready Terminated System request Activate Deactivate Deactivate Suspended Waiting Completion

SUSPENDED PROCESSES Suspended processes Do not reside in main memory Continue to be included in the process table Can distinguish between two types of suspended processes: Waiting for the completion of some request (waiting_suspended) Ready to run (ready_suspended).

CONTEXT SWITCHING When one process is running on a CPU and another needs to run on the same CPU, we need to switch between the processes This is called a context switch (or a state save and state restore) executing interrupt or system call save state into PCB 0 idle reload state from PCB 1 idle interrupt or system call executing save state into PCB 1 idle executing reload state from PCB 0

CONTEXT SWITCHING The last step of a context switch is typically to load the program counter for the process that is about to run Context switch has a time cost Dependent on hardware (e.g., # of machine registers) Not executing user processes during the time a context switch is occurring

OPERATIONS ON PROCESSES Process creation fork() exec() The argument vector Process deletion kill() signal()