Processes and OS basics. RHS – SOC 2 OS Basics An Operating System (OS) is essentially an abstraction of a computer As a user or programmer, I do not.

Slides:



Advertisements
Similar presentations
Part IV: Memory Management
Advertisements

Chapter 6: Memory Management
Virtual Memory main memory can act as a cache for secondary storage motivation: Allow programs to use more memory that there is available transparent to.
CMPT 300: Operating Systems I Dr. Mohamed Hefeeda
CMPT 300: Final Review Chapters 8 – Memory Management: Ch. 8, 9 Address spaces Logical (virtual): generated by the CPU Physical: seen by the memory.
Chapter 101 Virtual Memory Chapter 10 Sections and plus (Skip:10.3.2, 10.7, rest of 10.8)
Operating System Support Focus on Architecture
Virtual Memory Chapter 8. Hardware and Control Structures Memory references are dynamically translated into physical addresses at run time –A process.
1 Chapter Seven Large and Fast: Exploiting Memory Hierarchy.
Multiprocessing Memory Management
CS 104 Introduction to Computer Science and Graphics Problems
Memory Management 2010.
CMPT 300: Final Review Chapters 8 – Memory Management: Ch. 8, 9 Address spaces Logical (virtual): generated by the CPU Physical: seen by the memory.
1 Chapter 8 Virtual Memory Virtual memory is a storage allocation scheme in which secondary memory can be addressed as though it were part of main memory.
Chapter 11 Operating Systems
©Brooks/Cole, 2003 Chapter 7 Operating Systems Dr. Barnawi.
MEMORY MANAGEMENT By KUNAL KADAKIA RISHIT SHAH. Memory Memory is a large array of words or bytes, each with its own address. It is a repository of quickly.
Operating Systems CS208. What is Operating System? It is a program. It is the first piece of software to run after the system boots. It coordinates the.
Computer Organization and Architecture
Virtual Memory Deung young, Moon ELEC 5200/6200 Computer Architecture and Design Lectured by Dr. V. Agrawal Lectured by Dr. V.
1  2004 Morgan Kaufmann Publishers Chapter Seven.
1  1998 Morgan Kaufmann Publishers Chapter Seven Large and Fast: Exploiting Memory Hierarchy (Part II)
1 CSE SUNY New Paltz Chapter Seven Exploiting Memory Hierarchy.
Operating Systems Concepts 1. A Computer Model An operating system has to deal with the fact that a computer is made up of a CPU, random access memory.
What do operating systems do? manage processes manage memory and computer resources provide security features execute user programs make solving user.
Layers and Views of a Computer System Operating System Services Program creation Program execution Access to I/O devices Controlled access to files System.
Virtual Memory By: Dinouje Fahih. Definition of Virtual Memory Virtual memory is a concept that, allows a computer and its operating system, to use a.
An Introduction to Operating Systems. Definition  An Operating System, or OS, is low-level software that enables a user and higher-level application.
Basics of Operating Systems March 4, 2001 Adapted from Operating Systems Lecture Notes, Copyright 1997 Martin C. Rinard.
Chapter 3 Operating Systems Concepts 1. A Computer Model An operating system has to deal with the fact that a computer is made up of a CPU, random access.
Chapter 3.1:Operating Systems Concepts 1. A Computer Model An operating system has to deal with the fact that a computer is made up of a CPU, random access.
Process Management A process is a program in execution. It is a unit of work within the system. Program is a passive entity, process is an active entity.
Tutorial 6 Memory Management
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 1: Introduction.
Chapter 3 Memory Management: Virtual Memory
CHAPTER 2 OPERATING SYSTEM OVERVIEW 1. Operating System Operating System Definition A program that controls the execution of application programs and.
Chapter 1 Computer System Overview Dave Bremer Otago Polytechnic, N.Z. ©2008, Prentice Hall Operating Systems: Internals and Design Principles, 6/E William.
Software GCSE COMPUTING.
Chapter 5 Operating System Support. Outline Operating system - Objective and function - types of OS Scheduling - Long term scheduling - Medium term scheduling.
Lecture 19: Virtual Memory
Lecture 3 Process Concepts. What is a Process? A process is the dynamic execution context of an executing program. Several processes may run concurrently,
IT253: Computer Organization
Chapter 7 Operating Systems. Define the purpose and functions of an operating system. Understand the components of an operating system. Understand the.
OPERATING SYSTEMS Lecture 3: we will explore the role of the operating system in a computer Networks and Communication Department 1.
Operating Systems. Overview What is an Operating System (OS) What is an Operating System (OS) What Operating Systems do. What Operating Systems do. Operating.
Chapter 1: Introduction and History  Where does the operating system fit in a computing system?  What does the operating system achieve?  What are the.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 9: Virtual Memory.
Computer Systems Week 14: Memory Management Amanda Oddie.
Introduction: Memory Management 2 Ideally programmers want memory that is large fast non volatile Memory hierarchy small amount of fast, expensive memory.
Multilevel Caches Microprocessors are getting faster and including a small high speed cache on the same chip.
1  2004 Morgan Kaufmann Publishers Chapter Seven Memory Hierarchy-3 by Patterson.
CS4315A. Berrached:CMS:UHD1 Introduction to Operating Systems Chapter 1.
Operating Systems: Summary INF1060: Introduction to Operating Systems and Data Communication.
Memory Management Chapter 5 Advanced Operating System.
1 Chapter 2: Operating-System Structures Services Interface provided to users & programmers –System calls (programmer access) –User level access to system.
CS161 – Design and Architecture of Computer
Chapter 2 Memory and process management
Memory COMPUTER ARCHITECTURE
Chapter 8: Main Memory.
CS161 – Design and Architecture of Computer
Swapping Segmented paging allows us to have non-contiguous allocations
Main Memory Management
O.S Lecture 13 Virtual Memory.
Lecture 14 Virtual Memory and the Alpha Memory Hierarchy
Chapter 9: Virtual-Memory Management
Morgan Kaufmann Publishers Memory Hierarchy: Virtual Memory
Introduction to Operating Systems
CSE 153 Design of Operating Systems Winter 2019
COMP755 Advanced Operating Systems
Operating Systems: Internals and Design Principles, 6/E
Presentation transcript:

Processes and OS basics

RHS – SOC 2 OS Basics An Operating System (OS) is essentially an abstraction of a computer As a user or programmer, I do not care too much about the specifics of a given com- puter – I think of a computer in abstract terms A bit like interfaces and implementations…

RHS – SOC 3 OS Basics A computer monitor…

RHS – SOC 4 OS Basics An Operating System shields us from dealing with concrete details of a computer We can think of a computer in terms of –A file system –Memory –Input/output devices …and not worry about details

RHS – SOC 5 OS Basics As application deve- lopers, we interface with the OS, not the hardware Still need a basic understanding of the way an OS works

RHS – SOC 6 OS Basics Main tasks for an OS: –Hardware operation –Software operation –Memory management –File system management –Security –Networking

RHS – SOC 7 Process management Software operation more specifically means process management What is a process…? A process is a running instance of a computer program Similar to the relation between a class and an object

RHS – SOC 8 Process management Class / Program –A specification of behavior –Passive collection of instructions –Only one definition –Resides in secondary storage (hard disk) Object / Process –A ”living” entity –Active execution of instructions –Multiple instances can coexist (usually) –Resides in primary storage (RAM)

RHS – SOC 9 Process management The OS manages the life-cycle of a process –Starting the process –Managing the process while active –Terminating the process

RHS – SOC 10 Process management The complexity of life-cycle management depends on the OS category Single-tasking OS – only one process can be active at any time Multi-tasking OS – many processes can be active at any time Almost all modern OS are multi-tasking – we will focus on that category

RHS – SOC 11 Process management In a multi-tasking OS, we can start many tasks, but only have one CPU available CPU resources – and other resources – must thus be shared among processes Managing this is a key OS task! A process may thus be in more states than just ”running” or ”not running”

RHS – SOC 12 Process life-cycle A multi-tasking OS will always include a process scheduler The process scheduler must decide when resources can be assigned to a specific process, thus making it able to execute

RHS – SOC 13 Process life-cycle Process scheduling is not trivial! What is the overall goal…? –Fairness –Responsiveness –Meeting a deadline –Minimising waiting time –…and other possible objectives

RHS – SOC 14 Process life-cycle In a modern OS, processes can be assigned a priority The lower priority, the fewer resources assigned to the process Enables the OS to do certain tasks ”in the background”, like –Virus scan –Disk defragmentation

RHS – SOC 15 Process life-cycle Starting a process: –First, the process is created – this involves loading a copy of the program from secondary storage into RAM –The process is then put in a waiting state by the process scheduler –The process will remain in the waiting state, until the resources needed by the process become available

RHS – SOC 16 Process life-cycle Running a process: –At some point, the needed resources ar assigned to the process, and the process can start executing. The process is now running –During the execution, the process can become blocked or again become waiting –A process becomes blocked if it has to wait for some other action to complete, like opening a file

RHS – SOC 17 Process life-cycle Terminating a process –At some point, the process has completed its task (perhaps stopped by user) –The state of the process then becomes terminated –The OS can then reclaim the memory used by the (now terminated) process

RHS – SOC 18 Process life-cycle Created WaitingBlocked RunningTerminated

RHS – SOC 19 Exercises What is the primary purpose of an operating system? What is the relation between a program and a process? Try to press Ctrl+Shift+Esc, which brings up the task manager. Go to Processes – how many processes are (approximately) running on your PC? How many of them can you recognise? What makes a multi-tasking OS complex? What type of priority should a Virus Scanner run with (high or low)?

RHS – SOC 20 Memory management A very important part of managing a process is memory management The OS has to make sure that memory is available in a transparent and efficient manner for the process The OS uses a technique called virtual memory for enable this

RHS – SOC 21 Memory management When a process is started, the OS will set up a virtual memory address space for the process The process only interacts with the virtual memory adress space The OS maps the virtual memory adress space to physical memory (either RAM or secondary storage, e.g hard drive)

RHS – SOC 22 Memory management

RHS – SOC 23 Memory management Since the OS cannot predict how much memory a process will need, it is typically given a large virtual address space 32-bit OS: Up to 4 GB Sum of virtual address spaces often much larger than available RAM

RHS – SOC 24 Memory management In the virtual address space, we have three types of data –Program data; the program itself –Stack data; data which is allocated when methods are called, etc. (local variables) –Heap data; data which is dynamically allocated, using the new statement

RHS – SOC 25 Memory management Program data Stack data Heap data

RHS – SOC 26 Memory management Using RAM as physical memory is much more efficient than using the hard drive OS will continuously try to map as much virtual memory to RAM as possible Memory is divided into pages (typically less than 1 Mb) – RAM can be considered a cache of most used pages

RHS – SOC 27 Memory management Whenever a process accesses (virtual) memory, the OS looks up the correspon- ding page of physical memory –If the page is already in RAM, fine (page hit) –If the page is in secondary storage, it is swapped into RAM (page fault) What page is then swapped out…?

RHS – SOC 28 Memory management A page fault is expensive, since it involves copying data from secondary storage OS tries to minimise number of page faults Usually, the OS will swap out the Least Recently Used (LRU) page

RHS – SOC 29 Memory management In general, data placement is always a compromise between speed and volume Most modern CPUs have several layers of internal memory, with a similar strategy for memory management Managed by the CPU, not the OS

RHS – SOC 30 Memory management

RHS – SOC 31 Memory management Other aspects of memory management –Security; preventing exploits such as buffer overruns or other malicious attacks –Inter-process communication; when two processes need to exchange data –Optimisation; OS cleans up memory when processes are terminated, and relocates memory to larger contiguous blocks

RHS – SOC 32 Exercises What are the advantages of using Virtual Memory address spaces? What happens if the running processes use more virtual memory than the amount of available physical memory? What is a page hit? a page fault? Why should the OS try to minimise the number of page faults? Can you think of other strategies for swapping out memory pages than the LRU (Least Recently Used) strategy? See if you can find some information about a modern CPU on the Internet (e.g Intel Core i7). How many layers of memory cache are on the chip? How much memory is in each layer?