CS 390 Unix Programming Environment

Slides:



Advertisements
Similar presentations
Chapter 3 Process Description and Control
Advertisements

Chapter 10 Operating Systems.
Operating System Support Focus on Architecture
Structure of Processes
Introduction to Operating Systems – Windows process and thread management In this lecture we will cover Threads and processes in Windows Thread priority.
Review: Operating System Manages all system resources ALU Memory I/O Files Objectives: Security Efficiency Convenience.
OS Spring’03 Introduction Operating Systems Spring 2003.
Advanced OS Chapter 3p2 Sections 3.4 / 3.5. Interrupts These enable software to respond to signals from hardware. The set of instructions to be executed.
Memory Management 1 CS502 Spring 2006 Memory Management CS-502 Spring 2006.
CS-3013 & CS-502, Summer 2006 Memory Management1 CS-3013 & CS-502 Summer 2006.
Chapter 9 Virtual Memory Produced by Lemlem Kebede Monday, July 16, 2001.
Chapter 11 Operating Systems
Computer Organization and Architecture
1 Process Description and Control Chapter 3 = Why process? = What is a process? = How to represent processes? = How to control processes?
Layers and Views of a Computer System Operating System Services Program creation Program execution Access to I/O devices Controlled access to files System.
Memory Management ◦ Operating Systems ◦ CS550. Paging and Segmentation  Non-contiguous memory allocation  Fragmentation is a serious problem with contiguous.
Process Description and Control Chapter 3. Major Requirements of an OS Interleave the execution of several processes to maximize processor utilization.
Chapter 3 Operating Systems Introduction to CS 1 st Semester, 2015 Sanghyun Park.
OPERATING SYSTEM OVERVIEW. Contents Basic hardware elements.
Recall: Three I/O Methods Synchronous: Wait for I/O operation to complete. Asynchronous: Post I/O request and switch to other work. DMA (Direct Memory.
Computer Architecture and Operating Systems CS 3230: Operating System Section Lecture OS-1 Process Concepts Department of Computer Science and Software.
Chapter 7 Operating Systems. Define the purpose and functions of an operating system. Understand the components of an operating system. Understand the.
By Teacher Asma Aleisa Year 1433 H.   Goals of memory management  To provide a convenient abstraction for programming.  To allocate scarce memory.
Chapter 2 Processes and Threads Introduction 2.2 Processes A Process is the execution of a Program More specifically… – A process is a program.
Computer Systems Week 14: Memory Management Amanda Oddie.
Silberschatz, Galvin and Gagne  Operating System Concepts Process Concept An operating system executes a variety of programs:  Batch system.
Main Memory. Chapter 8: Memory Management Background Swapping Contiguous Memory Allocation Paging Structure of the Page Table Segmentation Example: The.
Virtual Memory The memory space of a process is normally divided into blocks that are either pages or segments. Virtual memory management takes.
1  process  process creation/termination  context  process control block (PCB)  context switch  5-state process model  process scheduling short/medium/long.
Processes, Threads, and Process States. Programs and Processes  Program: an executable file (before/after compilation)  Process: an instance of a program.
Process Description and Control Chapter 3. Source Modified slides from Missouri U. of Science and Tech.
Chapter 2 Process Management. 2 Objectives After finish this chapter, you will understand: the concept of a process. the process life cycle. process states.
1 Structure of Processes Chapter 6 Process State and Transition Data Structure for Process Layout of System Memory THE DESIGN OF THE UNIX OPERATING SYSTEM.
Memory Management OS Fazal Rehman Shamil. swapping Swapping concept comes in terms of process scheduling. Swapping is basically implemented by Medium.
Processes 2 Introduction to Operating Systems: Module 4.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 4: Processes Process Concept Process Scheduling Types of shedulars Process.
Copyright © Curt Hill More on Operating Systems Continuation of Introduction.
Memory management The main purpose of a computer system is to execute programs. These programs, together with the data they access, must be in main memory.
Advanced Operating Systems CS6025 Spring 2016 Processes and Threads (Chapter 2)
Virtual Memory.
Introduction to Kernel
Memory Management.
Processes and threads.
Resource Management IB Computer Science.
Chapter 2 Memory and process management
Process Management Process Concept Why only the global variables?
Structure of Processes
OPERATING SYSTEMS CS3502 Fall 2017
Modeling Page Replacement Algorithms
Intro to Processes CSSE 332 Operating Systems
Main Memory Management
Structure of Processes
Process Models, Creation and Termination
Module IV Memory Organization.
Process & its States Lecture 5.
Modeling Page Replacement Algorithms
Process Description and Control
Process Description and Control
CSE 451: Operating Systems Autumn 2005 Memory Management
Process Control B.Ramamurthy 2/22/2019 B.Ramamurthy.
CSE 451: Operating Systems Autumn 2003 Lecture 9 Memory Management
CS149D Elements of Computer Science
Unix Process Control B.Ramamurthy 4/11/2019 B.Ramamurthy.
CSE 451: Operating Systems Autumn 2003 Lecture 9 Memory Management
Chapter 2 Processes and Threads 2.1 Processes 2.2 Threads
Processes – Part I.
CS510 Operating System Foundations
OPERATING SYSTEMS MEMORY MANAGEMENT BY DR.V.R.ELANGOVAN.
Structure of Processes
Presentation transcript:

CS 390 Unix Programming Environment Topics to be covered: Memory Management Process Scheduling CS390 - Unix Programming Environment

CS390 - Unix Programming Environment Memory Management Memory is an important resource that has to be managed with the help of memory manager Memory Manager is a component of the OS responsible for managing memory Allocate and deallocate processes to and from the memory Allocate memory to processes that are currently being used Deallocate memory from processes that have ended Unlike PC’s, UNIX OS use very sophisticated memory management algorithms to make efficient use of memory resources CS390 - Unix Programming Environment

CS390 - Unix Programming Environment Types of Memory Main Memory The physical RAM, also called Real memory processes can only be run when both the program code, and program data resides in main memory Cache Memory The cache is a small amount of high-speed memory, usually with a memory cycle time comparable to the time required by the CPU to fetch one instruction. The cache is usually filled from main memory when instructions or data are fetched into the CPU. Swap space Disk memory used to hold data that is not in Real or File System CS390 - Unix Programming Environment

CS390 - Unix Programming Environment Virtual Memory (VM) Used to enlarge the available address space beyond the physical address space Total Memory = Virtual Memory + Main Memory It is the responsibility of the Memory manager to keep track of processes, whether they are in Main or Virtual Memory All current running processes must be in the Main Memory CS390 - Unix Programming Environment

CS390 - Unix Programming Environment Virtual Memory Contd. Most modern computers have special hardware called a memory management unit (MMU). This unit sits between the CPU and the memory unit If CPU wants to access memory (whether it is to load an instruction or load or store data), it sends the desired memory address to the MMU, which translates it to another address The address generated by the CPU is called a virtual address, and the address it gets translated to by the MMU is called a physical address. CS390 - Unix Programming Environment

CS390 - Unix Programming Environment Memory Manager Issues Often the number of processes that an OS needs to manage have memory requirements that exceed the amount of available memory Move processes to and from disk to the main memory Disk access is much slower than main memory Needs efficient algorithms to effectively manage all system processes Common techniques Swapping Demand Paging CS390 - Unix Programming Environment

CS390 - Unix Programming Environment Swapping When the number of processes have memory requirements that exceed the amount of main memory, some processes need to be moved to the disk Swapping systems require that the entire process has to be in main memory in order to run the process Consists of three parts Managing space in the swap device (secondary memory) Swapping process out of main memory Swapping process back into the main memory CS390 - Unix Programming Environment

CS390 - Unix Programming Environment Demand Paging Virtual address space is divided into equally sized units called pages Pages typically range from 1K to 8k Now the entire process need not to be in the main memory to execute The act of moving back and forth the pages from the Main memory to the virtual memory is called Paging If a process accesses a page and that page is not in Main memory a page fault occurs Move the page from the virtual memory to the main memory CS390 - Unix Programming Environment

CS390 - Unix Programming Environment Processes A task in operation is called as a Process A process is created by fork system call at the lowest level One can check what processes are running using the ps command We also know how to terminate a process using the kill command Lets now see how processes can be scheduled CS390 - Unix Programming Environment

CS390 - Unix Programming Environment Process scheduling As a time sharing system, the UNIX system kernel directly controls how processes are scheduled The Kernel suspends a process when its quantum time expires If a process wants to get the attention of the kernel, it uses Interrupts CS390 - Unix Programming Environment

CS390 - Unix Programming Environment Interrupts When an Interrupt occurs, the current process is suspended and the kernel examines the cause and services the interrupt After the interrupt has been handled, the suspended process either resumes execution or preempted Pre-emption is a process of taking away the control CS390 - Unix Programming Environment

CS390 - Unix Programming Environment Process state Diagram Interrupt, Interrupt return User Running System call, interrupt Kernel Running return Return to user Zombie Preempt exit Preempted sleep Reschedule process Asleep in memory Wakeup Ready to run Enough memory Swap out Swap in, Swap out Created using fork Not enough memory Wakeup Sleep Swapped Ready to run, swapped CS390 - Unix Programming Environment

CS390 - Unix Programming Environment Interrupt contd… Current Process Suspend resume time Terminal interrupt handler Process interrupt completed Terminal interrupt CS390 - Unix Programming Environment

Process Scheduling contd… A user can specify when a process should run using user-level commands at command batch command nice command sleep command wait command nohup command CS390 - Unix Programming Environment

CS390 - Unix Programming Environment at command One can specify when the commands should run using the at command $ at 0500 Jan 18 echo “Don’t forget the meeting” | mail you CNTL-D The above command will mail you a reminder at 5:00 am on Jan 18 about the meeting -f option: run a sequence of commands contained in a file $ at –f scriptfile 6 am Monday This will run scriptfile at 6 A.M. on Monday CS390 - Unix Programming Environment

CS390 - Unix Programming Environment at command contd… You can see the listing of all at jobs you have scheduled, using the –l option, which returns ID number and scheduled time for each of your at jobs $ at –l To remove a job from the queue use –r option CS390 - Unix Programming Environment

CS390 - Unix Programming Environment batch command The batch command lets the user defer the execution, but does not give control as to when it is supposed to run $ batch <<! cat mybook | lp CS390 - Unix Programming Environment

CS390 - Unix Programming Environment Process Priorities The kernel assigns the CPU to a process for a time slice When the time of a process is elapsed it is placed in one of the several priority queues. All the processes have some priority associated with them CS390 - Unix Programming Environment

CS390 - Unix Programming Environment The nice command The nice command allows a user to execute a command with a lower-than-normal priority Priority = priority index + nice value You can decrease the priority of a command by using nice. It will run slower and takes less CPU time. Advantage: you are being nice to your neighbors $ nice –19 profit CS390 - Unix Programming Environment