Cool Container Crew 2. BACKGROUND

Size: px
Start display at page:

Download "Cool Container Crew 2. BACKGROUND"

Transcription

1 Cool Container Crew GROUP MEMBERS Alexander Lent [ lenta@uw.edu ] Garrett Marconet [ gmarco@uw.edu ] Carmen Hanish [ carmenyh@uw.edu ] Thomas Nguyen [ tomn@uw.edu ] Vadim Eksarevskiy [ veksarev@uw.edu ] ABSTRACT This work describes adding containers to xv6, an open source operating system designed for teaching fundamentals and showing the inner workings of an OS. xv6 is simple enough to be relatively straightforward to reason about, and allows the demonstration of what containers are and how they can be implemented. At the same time, it is robust enough to allow a full-fledged implementation and can allow others to reason about parts that can be further improved and added on in the future, making it the perfect platform to demonstrate a container implementation. In this paper, we address the benefits of containers, how we implemented them in xv6, what different variations of them exist, and how containers can be expanded upon. 1. INTRODUCTION This paper discusses our container implementation for xv6, which aims to allow groups to be created with process isolation, memory limiting, and CPU priorities. This was implemented through adding a notion of pgroups. Pgroups are essentially a mix between namespaces and cgroups, providing both in one. Specifically, they add process isolation, by preventing processes in different pgroups from interacting with or seeing each other, except for the root pgroup. Additionally, they also provide I/O isolation for the console, preventing multiple shells running simultaneously in different pgroups from interfering from each other. Throughout this paper, the terms group, pgroup, and container are used interchangeably. As far as the aspects of pgroups that were implemented, this project added memory limiting, making it possible to limit how much memory a single pgroup can use. Dynamic CPU time distribution based on pgroup settings was attempted initially, but we ran into issues implementing it and ended up giving each container an equal portion of CPU time. Our implementation supports multi-core configurations, while preserving the integrities guaranteed by our definition of pgroups. Specifically, we support up to 8 cores. The rest of the paper is organized as follows. 2 gives the background for this project, including linux namespaces and cgroups. 3 details the related work of other implementations of containers, both in xv6 and in linux. 4 discusses the details of our project, including the initial design and final implementation. 5 presents experimental results, primarily performance effects of our implementation. 6 notes ways to improve this work, including bugs that could be fixed and possible additional features. Finally, 7 describes what lessons we learned during this project, and 8 provides our conclusion from it. 2. BACKGROUND Containers are a notion similar to that of Virtual Machines. They are made primarily for the purposes of providing isolation and allowing multiple potentially adversarial processes to share a single physical machine. As cloud computing becomes more widespread, guaranteeing a given cloud instance is isolated from others running on the same machine is becoming more important. Modern Linux containers work by creating namespaces and cgroups that provide different levels of isolation and resource limiting for each container. Namespaces allow each container to have multiple or all of: isolated processes, file system, memory, I/O, etc. They attach each process to a certain container, and only allow that process to access and see things in a way consistent with the view presented by the container. Cgroups, on the other hand, provide a way to limit the resources used by each container. They do not provide isolation by themselves but set a limit in the amount of memory and/or CPU usage that a single container can consume. This is useful for systems where fair allocation is important, such as cloud systems with multiple users, who may be requesting different amounts of memory and/or CPU usage. While Virtual Machines, when implemented properly, can provide near complete security and isolation, they incur a large overhead by having multiple guest operating systems running at the same time. When running multiple VM instances of the same guest OS, many of the resources stored by the hypervisor are duplicated and redundant. Additionally, extra overhead is added due to a guest OS having to go through the underlying hypervisor whenever they need to

2 communicate with the hardware. All of this combined introduces a large amount of overhead to simple operations such as disk access, therefore inevitably slowing down the system. Containers as implemented are inherently less secure than VMs but are good enough for most purposes. They are also more efficient than VMs. They are especially useful in cases such a single user running multiple programs that have different dependencies, relying on different versions of some code. In this case, the user is not concerned about the security, but needs isolation in order to allow both programs to run simultaneously. While VMs can provide this, they do so with a large amount of overhead. In the case of containers, however, this overhead is much lower, while still allowing the programs to be run in tandem due to both seeing their necessary dependency code. Therefore, it is easy to see the particular applications of containers, and why it is interesting to build them in a system like xv6, in order to make it easier for others to understand the basics behind containers and to see how they are implemented in a relatively straightforward system. 3. RELATED WORK On GitHub, there is a repository that adds container support to xv6 [1]. This work is based on adding a container struct in container.h. The container struct is similar to our pgroup one, but also has a disk use limit, a maximum number of processes for each container, and a map to every process. This repository does memory limiting through modifying kalloc and kfree. This allows them to have control over memory allocation for pages outside of the user virtual memory for each process. In order to better gain an understanding of container isolation, our group did not look at the existing xv6c implementation before our implementation of pgroups was completed. 4. IMPLEMENTATION 4.1 Initial Design Building ps The first portion to implement is a simplified version of the unix command ps which lists information about all processes running on a machine at a given time. This is necessary to show process isolation and resource limiting later on. To implement ps, a getprocs() system call is implemented that returns a list of all running processes in the environment and information about them. This system call is then used to implement the rudimentary version of ps that prints information about all running processes Namespace Data Structure The next part of implementing containerization is adding support for a basic form of namespaces. This allows processes to be grouped together and for resources to be managed independently between groups. The main portion of adding namespaces is adding a field to the proc struct that is used as an index into an array of namespaces. The existing system calls and kernel exit/entries will be verified to ensure that the kernel operates with namespaces in mind. Furthermore, the rest of the kernel will need to be verified to ensure that other operations (such as process initialization and forking) are done with the knowledge of namespaces in mind. To create a new namespace, a user will use a createns() system call, which will need to be implemented. This system call would create a new namespace object Process Isolation Processes will need to be isolated between containers so that different containers do not see each other s processes unless the process was from the root where the container was spawned. This isolation should be able to be verified quickly by getprocs() and is the basic root of the containerization to be implemented CPU Resource Limiting The goal with CPU Resource limiting is to allow for lower and higher priority containers based on the logical importance of their tasks. The CPU should be optimally utilized and kept as busy as possible if work is needed to be done. The preliminary idea on how to implement this is to use something akin to a standard OS scheduler. It could use something as simple as timed interrupts to ensure every container gets to run for an equal amount of time, cycling between containers. In an attempt to design a scheduler more from the ground up, the scheduler algorithm for these pgroups was to be designed without looking at scheduler algorithms online. The initial idea for implementation was to give all processes a ticker to see how long the process has been waiting and bump the ticker by the process group priority each time the process is skipped by the scheduler, so tasks waiting longer with a higher priority are more likely to be ran by the scheduler next time. This also in theory helps ensure that so long as ridiculous priority ratios are not given to different pgroups, different processes will not starve.

3 4.1.5 Memory Resource Limiting To limit access to memory resources, sbrk() will be modified to limit the memory allocated to each namespace and processes within it. The amount of memory used by each namespace will be the sum of the number of physical pages used by each of of its processes. The limits will be set on creation of the namespace. 4.2 Final Implementation pgroup Creation A pgroup struct is created through the user program pgroupcreate. pgroupcreate takes two optional parameters: the maximum number of pages that can be allocated for this group and the CPU priority given to the group for scheduling purposes. These variables are then stored with the pgroup struct and the defaults for them are the maximum number of pages for the memory limit, and the highest CPU priority. By default, xv6 launches a shell on startup. Therefore, it also makes sense for each new container to immediately start a new shell for interacting with that container. This shell is a fully-fledged shell that is identical to that of the original one, with the caveat of only being able to see console I/O when the console has the shell s group_id as the current active container. This will be described more in detail later. This changed from the initial design in the name change from namespace to pgroup, which was to indicate that this implementation falls somewhere between the cgroups and namespaces of the Linux kernel implementation Console Isolation Console isolation is a concept we added to xv6 that was not in our initial design document. Once we began experimenting with the other features, it became apparent that an intuitive way to direct input and output to a particular process or container would be invaluable. Our implementation of console isolation is essentially a special case of I/O isolation. Specifically, we modified two methods in console.c: consoleread and consolewrite. For reading input from the console, we check if the running process is within the active pgroup and if it is not, we yield the CPU and continue execution at the start of the input loop. For isolating console output, we had more options. The first option was to maintain a buffer of output for each pgroup. However, we felt that the storage overhead required was not worth it and we were weary of output possibly being truncated if a process printed too much. Another option for output isolation was to print all lines from any group to the console but prepend the pgroup ID to any line printed from outside of the active group. We decided against this as well, since it would be messy and yield output that is hard to follow and breaks up the running program s output. The solution we ultimately decided to go with was similar to our solution for handling input. If a process in a non-active group attempts to print something, it will return to the start of the output loop and yield the CPU. While this solution limits the amount of background computation a printing process can do, we figured such a solution would be best for our implementation of xv6 as a research operating system since it resulted in the simplest and cleanest codebase. With that in mind, if xv6 were focused more on an efficient user experience, a variation on the first option would be ideal. In this variation, we would maintain a linked-list of strings that each represent a call to consolewrite while the associated pgroup is in the background. As soon as the pgroup became active, we would iterate through this linked list, printing each item. This solution would still allow for applications that print to the console to run in the background without dirtying the console while another pgroup is running. The next steps for I/O isolation is to implement a general solution on xv6. Such an implementation would be remarkably similar to our solution for console isolation, in that it would modify the read and write calls from all inodes on xv6 to be aware of pgroups and operate in a way that does not break isolation Process Isolation In order to support process isolation, each proc struct, which stores information about a given process, was modified to add a group_id to it. This is used throughout the whole implementation to support pgroups. It is worth noting that currently it is impossible to change a process s container after it has started running, although this should not be needed. This also has a workaround in the form of forking the current process into a different container, and killing the parent process, which effectively achieves the goal of change a process s container. In a future iteration of our containers in xv6, we intend to fix this bug. Process isolation takes multiple forms, with the most fundamental one being the inability of processes in different containers to interact with each other. Specifically, all the system calls are modified to check that the operation is valid, in the sense that the process doing the operation is not trying to perform it on a process in a container which it should not be able to interact with. This includes the newly added ps command, which if it is run from a process within a group, is only able to see and list processes that are in that group.

4 In addition to this, process creation was modified to ensure that processes in different containers had separate pid counters. This was implemented through modifying the function that creates a new process to instead give each process a pid based on the counter for that specific pgroup, rather than a global counter. Any functions that created new processes before the OS finished booting and set up containers now used a default group_id of 0 for the purpose of pid creation CPU Resource Limiting The hope for allowing priorities to different pgroups was to let certain groups use more processor time in relation to other groups and finish tasks quicker. The caveat to allowing more processor time is that a good scheduler should ensure scheduling is still relatively fair, and that processes do not starve or have an extremely long response time. After implementing the scheduler algorithm designed out in the initial implementation section that was supposed to prioritize processes based on their pgroup priority, multiple testing programs were written. One approach was to time how long it took to compute a large amount of primes numbers starting from one, and the other was to time and count how many times the scheduler picked a certain process that consistently yielded in relation to other similar processes that were given different priorities. The testing programs revealed that the scheduler implementation and design did not work well. When there weren t many processes, the scheduler would schedule everything fairly and give equal CPU time. Occasionally with the right number of processes and setup the scheduler would work correctly, giving different amounts of CPU time to different processes based on their group priority, but overall the slight slowdown was not worthwhile and the scheduling was simply not correct. The scheduler may have given equal time to each process because the initial design did not account for such a small number of processes being switched between so quickly, so the counting of wait times did not work correctly. The second attempt at designing the scheduler over produced dramatically different results and did give different CPU times to different processes, but did not prioritize based on the group priority. The original xv6 scheduler cycled through all the processes and picked the first runnable one in the table. In the end, the original xv6 scheduler was reverted to and slightly modified to pick the first runnable process after the last one ran so that each process would be given a similar priority Memory Limiting Memory limiting is implemented through changes to allocuvm, deallocuvm, and pipe. As such, it does not take into account memory used to set up the kernel portion of each process, but does not any changes to a process heap. The memory limit for a given group is set at the time of its creation, through the second parameter to the createpgroup call. This sets the limit of the number of pages. When any of the affected methods then attempt to allocate pages for a process s use, they call change_mem_used to request the amount of pages desired. This method then checks how many pages the current group has used, compared with the maximum amount it may use, and from there returns the number of pages that the given method is allowed to use. The changes to the initial design were namely that, as part of testing this feature, a user program memleak was added. This attempts to allocate as much memory as possible in the current group, going into an infinite loop when the maximum is allocated. Another change was to have memory requests go through allocuvm, deallocuvm, and pipe rather than sbrk, because these methods had the code to allocate or deallocate memory at the page level. 5. EXPERIMENTAL RESULTS Our implementation of containers in xv6 has relatively few places that could serve as a bottleneck for performance. All added features or either O(1) or O(n) for n < 64 worst case runtime and memory complexity. That said, we decided to include brief benchmarks and summaries of all user-facing programs and operations. Runtime Memory Usage pgroupcreate ~0ms sh overhead pgrouplist ~2ms 164 bytes + normal user program overhead Group switching ~0ms 4 bytes ps ~1ms 94 bytes + normal user program overhead As one can see from the experimental runtimes, there is near-negligible time added by our container implementation.

5 5.1 Cost from Modification and Addition of Global Variables We added a global data structure and expanded one other. The data structure we added was the grouptable, which holds a spinlock and 8 pgroups. The pgroup struct is currently 20 bytes, and the grouptable is 212 bytes. The structure we expanded was the ptable, which we did by adding 2 additional fields, or 8 bytes, to the proc struct. This then causes an additional usage of 512 bytes through the ptable. 6. NEXT STEPS 6.1 Known Bugs As with any operating system, our implementation of containers in xv6 has its fair share of bugs. For one, pgroupcreate will fail if run repeatedly without switching to the new groups. We have two ideas for why this bug may be happening. Our first intuition is that it has something to do with too much data being pushed to the stack at once, so new data is going over the edge and causing an issue. Another possible explanation is that our scheduler is faulty and for some reason is not working properly once we get to a certain number of runnable processes. This is supported by the fact that the number of times we can run pgroupcreate without it failing (and without switching to the new groups) fluctuates between 3 and 5. Further, we have issues with a shell seemingly randomly crashing when running pgroupcreate multiple times in quick succession. We believe this is a symptom of the same underlying bug. 6.2 Desired Features As was discussed in the introduction to this paper, there are many different types of isolation that can be offered by containers, some of which we chose not to implement for the project. The most useful one that we could later add would be file system isolation, as this would bring containers closer to what VMs offer in terms of functionality. This could be implemented through a file system similar to copy-on-write fork. Such a file system would copy any directory or file that has a change from the root copy into a container. This would essentially achieve a state where all of the containers have their own file system state. In addition to this, I/O isolation could be expanded to encompass other forms of I/O besides the console (such as network and other devices). However, it is worth noting that currently xv6 lacks network support, so this would first need to be implemented for network isolation to become meaningful. Finally, dynamic CPU limiting based on variable parameters would also be a useful feature of our groups. This was originally part of the design, but was cut due to an impractical scheduler design. Implementing this would require advanced knowledge of CPU schedulers. Traditional linux containers often allow the choice of what to isolate, rather than doing it all at once. For this paper, it was a conscious choice to do it all at once, as this makes reasoning about the model easier and provides a more VM-like level of isolation. However, for purposes where only a single type of isolation might be required, it would be beneficial to split pgroups into different namespaces and cgroups so that a user has more control over the system. 7. LESSONS LEARNED In working on allowing different priorities to different groups, the scheduler was designed and written without looking at other scheduler implementations. The implementation of the new scheduler algorithm did not work, but a massive amount was learned about the scheduler along the way. In summary, going in blind and trying to design and implement an algorithm using only previous knowledge is not the best way to approach a new topic always. A lot of time was spent between the design and implementation, and a quick check may have revealed how the scheduler did not work the way we had originally thought. That s not to say designing on your own code is bad, but sinking a lot of time into something to not produce results visible by other people is occasionally frowned upon if they did not see the work put in. The implementation of the scheduler feels similar to hashcodes, where you should not go and write your hashcode algorithm blind but rather read a book first on how to do so, then go and implement said algorithm. 8. CONCLUSION The intent of this project was to design and implement containers within xv6. Process ID isolation was achieved, and multiple pgroups could be launched to run simultaneously on xv6. In our implementation, processes cannot see other processes running in different pgroups. In addition, each pgroup starts initially with a dedicated shell. Furthermore, memory limiting was implemented so that pgroups can be constrained to not take up all of the available memory from the underlying shared resources. Designing this project without looking at previous implementations allowed for a deeper understanding about how isolation of resources works. 9. REFERENCES [1]

Last class: OS and Architecture. OS and Computer Architecture

Last class: OS and Architecture. OS and Computer Architecture Last class: OS and Architecture OS and Computer Architecture OS Service Protection Interrupts System Calls IO Scheduling Synchronization Virtual Memory Hardware Support Kernel/User Mode Protected Instructions

More information

Last class: OS and Architecture. Chapter 3: Operating-System Structures. OS and Computer Architecture. Common System Components

Last class: OS and Architecture. Chapter 3: Operating-System Structures. OS and Computer Architecture. Common System Components Last class: OS and Architecture Chapter 3: Operating-System Structures System Components Operating System Services System Calls System Programs System Structure Virtual Machines System Design and Implementation

More information

Introduction. This project will focus primarily on processes.

Introduction. This project will focus primarily on processes. Project 2 Processes Introduction This project will focus primarily on processes. In this project, you will become familiar with: 1. Locks for kernel-level data structures; concurrency. 2. Implementing

More information

Chapter 3: Operating-System Structures

Chapter 3: Operating-System Structures Chapter 3: Operating-System Structures System Components Operating System Services System Calls System Programs System Structure Virtual Machines System Design and Implementation System Generation 3.1

More information

Module 3: Operating-System Structures

Module 3: Operating-System Structures Module 3: Operating-System Structures System Components Operating-System Services System Calls System Programs System Structure Virtual Machines System Design and Implementation System Generation Operating

More information

OS and Computer Architecture. Chapter 3: Operating-System Structures. Common System Components. Process Management

OS and Computer Architecture. Chapter 3: Operating-System Structures. Common System Components. Process Management Last class: OS and Architecture OS and Computer Architecture OS Service Protection Interrupts System Calls IO Scheduling Synchronization Virtual Memory Hardware Support Kernel/User Mode Protected Instructions

More information

Chapter 3: Operating-System Structures

Chapter 3: Operating-System Structures Chapter 3: Operating-System Structures System Components Operating System Services System Calls POSIX System Programs System Structure Virtual Machines System Design and Implementation System Generation

More information

Processes and Threads

Processes and Threads COS 318: Operating Systems Processes and Threads Kai Li and Andy Bavier Computer Science Department Princeton University http://www.cs.princeton.edu/courses/archive/fall13/cos318 Today s Topics u Concurrency

More information

Operating-System Structures

Operating-System Structures Operating-System Structures System Components Operating System Services System Calls System Programs System Structure Virtual Machines System Design and Implementation System Generation 3.1 Sana a University,

More information

Process Time. Steven M. Bellovin January 25,

Process Time. Steven M. Bellovin January 25, Multiprogramming Computers don t really run multiple programs simultaneously; it just appears that way Each process runs to completion, but intermixed with other processes Process 1 6 ticks Process 2 Process

More information

Chapter 10: Case Studies. So what happens in a real operating system?

Chapter 10: Case Studies. So what happens in a real operating system? Chapter 10: Case Studies So what happens in a real operating system? Operating systems in the real world Studied mechanisms used by operating systems Processes & scheduling Memory management File systems

More information

16 Sharing Main Memory Segmentation and Paging

16 Sharing Main Memory Segmentation and Paging Operating Systems 64 16 Sharing Main Memory Segmentation and Paging Readings for this topic: Anderson/Dahlin Chapter 8 9; Siberschatz/Galvin Chapter 8 9 Simple uniprogramming with a single segment per

More information

Project 3 Improved Process Management

Project 3 Improved Process Management Project 3 Improved Process Management Introduction This project will modernize process management in xv6. All process management will be impacted. New console control sequences will be implemented to support

More information

Introduction to Operating Systems Prof. Chester Rebeiro Department of Computer Science and Engineering Indian Institute of Technology, Madras

Introduction to Operating Systems Prof. Chester Rebeiro Department of Computer Science and Engineering Indian Institute of Technology, Madras Introduction to Operating Systems Prof. Chester Rebeiro Department of Computer Science and Engineering Indian Institute of Technology, Madras Week 03 Lecture 12 Create, Execute, and Exit from a Process

More information

CS 326: Operating Systems. Process Execution. Lecture 5

CS 326: Operating Systems. Process Execution. Lecture 5 CS 326: Operating Systems Process Execution Lecture 5 Today s Schedule Process Creation Threads Limited Direct Execution Basic Scheduling 2/5/18 CS 326: Operating Systems 2 Today s Schedule Process Creation

More information

Module 3: Operating-System Structures. Common System Components

Module 3: Operating-System Structures. Common System Components Module 3: Operating-System Structures System Components Operating System Services System Calls System Programs System Structure Virtual Machines System Design and Implementation System Generation 3.1 Common

More information

Frequently asked questions from the previous class survey

Frequently asked questions from the previous class survey CS 370: OPERATING SYSTEMS [THREADS] Shrideep Pallickara Computer Science Colorado State University L7.1 Frequently asked questions from the previous class survey When a process is waiting, does it get

More information

Mininet Performance Fidelity Benchmarks

Mininet Performance Fidelity Benchmarks Mininet Performance Fidelity Benchmarks Nikhil Handigol, Brandon Heller, Vimalkumar Jeyakumar, Bob Lantz, Nick McKeown October 21, 2012 1 Introduction This initial Mininet technical report evaluates the

More information

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

Processes. Sanzheng Qiao. December, Department of Computing and Software Processes Sanzheng Qiao Department of Computing and Software December, 2012 What is a process? The notion of process is an abstraction. It has been given many definitions. Program in execution is the most

More information

CS 162 Operating Systems and Systems Programming Professor: Anthony D. Joseph Spring Lecture 18: Naming, Directories, and File Caching

CS 162 Operating Systems and Systems Programming Professor: Anthony D. Joseph Spring Lecture 18: Naming, Directories, and File Caching CS 162 Operating Systems and Systems Programming Professor: Anthony D. Joseph Spring 2004 Lecture 18: Naming, Directories, and File Caching 18.0 Main Points How do users name files? What is a name? Lookup:

More information

Input/Output Management

Input/Output Management Chapter 11 Input/Output Management This could be the messiest aspect of an operating system. There are just too much stuff involved, it is difficult to develop a uniform and consistent theory to cover

More information

Linux Operating System

Linux Operating System Linux Operating System Dept. of Computer Science & Engineering 1 History Linux is a modern, free operating system based on UNIX standards. First developed as a small but self-contained kernel in 1991 by

More information

CS 162 Operating Systems and Systems Programming Professor: Anthony D. Joseph Spring Lecture 18: Naming, Directories, and File Caching

CS 162 Operating Systems and Systems Programming Professor: Anthony D. Joseph Spring Lecture 18: Naming, Directories, and File Caching CS 162 Operating Systems and Systems Programming Professor: Anthony D. Joseph Spring 2002 Lecture 18: Naming, Directories, and File Caching 18.0 Main Points How do users name files? What is a name? Lookup:

More information

Kernel Support for Paravirtualized Guest OS

Kernel Support for Paravirtualized Guest OS Kernel Support for Paravirtualized Guest OS Shibin(Jack) Xu University of Washington shibix@cs.washington.edu ABSTRACT Flexibility at the Operating System level is one of the most important factors for

More information

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

ECE 550D Fundamentals of Computer Systems and Engineering. Fall 2017 ECE 550D Fundamentals of Computer Systems and Engineering Fall 2017 The Operating System (OS) Prof. John Board Duke University Slides are derived from work by Profs. Tyler Bletsch and Andrew Hilton (Duke)

More information

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

CS 471 Operating Systems. Yue Cheng. George Mason University Fall 2017 CS 471 Operating Systems Yue Cheng George Mason University Fall 2017 Outline o Process concept o Process creation o Process states and scheduling o Preemption and context switch o Inter-process communication

More information

3. Process Management in xv6

3. Process Management in xv6 Lecture Notes for CS347: Operating Systems Mythili Vutukuru, Department of Computer Science and Engineering, IIT Bombay 3. Process Management in xv6 We begin understanding xv6 process management by looking

More information

Memory Management. Disclaimer: some slides are adopted from book authors slides with permission 1

Memory Management. Disclaimer: some slides are adopted from book authors slides with permission 1 Memory Management Disclaimer: some slides are adopted from book authors slides with permission 1 CPU management Roadmap Process, thread, synchronization, scheduling Memory management Virtual memory Disk

More information

Processes, Context Switching, and Scheduling. Kevin Webb Swarthmore College January 30, 2018

Processes, Context Switching, and Scheduling. Kevin Webb Swarthmore College January 30, 2018 Processes, Context Switching, and Scheduling Kevin Webb Swarthmore College January 30, 2018 Today s Goals What is a process to the OS? What are a process s resources and how does it get them? In particular:

More information

15 Sharing Main Memory Segmentation and Paging

15 Sharing Main Memory Segmentation and Paging Operating Systems 58 15 Sharing Main Memory Segmentation and Paging Readings for this topic: Anderson/Dahlin Chapter 8 9; Siberschatz/Galvin Chapter 8 9 Simple uniprogramming with a single segment per

More information

!! What is virtual memory and when is it useful? !! What is demand paging? !! When should pages in memory be replaced?

!! What is virtual memory and when is it useful? !! What is demand paging? !! When should pages in memory be replaced? Chapter 10: Virtual Memory Questions? CSCI [4 6] 730 Operating Systems Virtual Memory!! What is virtual memory and when is it useful?!! What is demand paging?!! When should pages in memory be replaced?!!

More information

System Call. Preview. System Call. System Call. System Call 9/7/2018

System Call. Preview. System Call. System Call. System Call 9/7/2018 Preview Operating System Structure Monolithic Layered System Microkernel Virtual Machine Process Management Process Models Process Creation Process Termination Process State Process Implementation Operating

More information

Spring It takes a really bad school to ruin a good student and a really fantastic school to rescue a bad student. Dennis J.

Spring It takes a really bad school to ruin a good student and a really fantastic school to rescue a bad student. Dennis J. Operating Systems * *Throughout the course we will use overheads that were adapted from those distributed from the textbook website. Slides are from the book authors, modified and selected by Jean Mayo,

More information

Distributed File Systems Issues. NFS (Network File System) AFS: Namespace. The Andrew File System (AFS) Operating Systems 11/19/2012 CSC 256/456 1

Distributed File Systems Issues. NFS (Network File System) AFS: Namespace. The Andrew File System (AFS) Operating Systems 11/19/2012 CSC 256/456 1 Distributed File Systems Issues NFS (Network File System) Naming and transparency (location transparency versus location independence) Host:local-name Attach remote directories (mount) Single global name

More information

Processes, PCB, Context Switch

Processes, PCB, Context Switch THE HONG KONG POLYTECHNIC UNIVERSITY Department of Electronic and Information Engineering EIE 272 CAOS Operating Systems Part II Processes, PCB, Context Switch Instructor Dr. M. Sakalli enmsaka@eie.polyu.edu.hk

More information

What is a Process? Processes and Process Management Details for running a program

What is a Process? Processes and Process Management Details for running a program 1 What is a Process? Program to Process OS Structure, Processes & Process Management Don Porter Portions courtesy Emmett Witchel! A process is a program during execution. Ø Program = static file (image)

More information

Chapter 3: Operating-System Structures

Chapter 3: Operating-System Structures 1 Chapter 3: Operating-System Structures System Components Operating System Services System Calls System Programs System Structure Virtual Machines System Design and Implementation System Generation 3.1

More information

OPERATING SYSTEMS UNIT - 1

OPERATING SYSTEMS UNIT - 1 OPERATING SYSTEMS UNIT - 1 Syllabus UNIT I FUNDAMENTALS Introduction: Mainframe systems Desktop Systems Multiprocessor Systems Distributed Systems Clustered Systems Real Time Systems Handheld Systems -

More information

Unit 5: Distributed, Real-Time, and Multimedia Systems

Unit 5: Distributed, Real-Time, and Multimedia Systems Unit 5: Distributed, Real-Time, and Multimedia Systems Unit Overview Unit 5 provides an extension to the core topics of operating systems. It introduces distributed systems and special-purpose operating

More information

(In columns, of course.)

(In columns, of course.) CPS 310 first midterm exam, 10/9/2013 Your name please: Part 1. Fun with forks (a) What is the output generated by this program? In fact the output is not uniquely defined, i.e., it is not always the same.

More information

Flash Drive Emulation

Flash Drive Emulation Flash Drive Emulation Eric Aderhold & Blayne Field aderhold@cs.wisc.edu & bfield@cs.wisc.edu Computer Sciences Department University of Wisconsin, Madison Abstract Flash drives are becoming increasingly

More information

OS Structure, Processes & Process Management. Don Porter Portions courtesy Emmett Witchel

OS Structure, Processes & Process Management. Don Porter Portions courtesy Emmett Witchel OS Structure, Processes & Process Management Don Porter Portions courtesy Emmett Witchel 1 What is a Process?! A process is a program during execution. Ø Program = static file (image) Ø Process = executing

More information

Memory Management. Disclaimer: some slides are adopted from book authors slides with permission 1

Memory Management. Disclaimer: some slides are adopted from book authors slides with permission 1 Memory Management Disclaimer: some slides are adopted from book authors slides with permission 1 Recap Paged MMU: Two main Issues Translation speed can be slow TLB Table size is big Multi-level page table

More information

CS 147: Computer Systems Performance Analysis

CS 147: Computer Systems Performance Analysis CS 147: Computer Systems Performance Analysis Test Loads CS 147: Computer Systems Performance Analysis Test Loads 1 / 33 Overview Overview Overview 2 / 33 Test Load Design Test Load Design Test Load Design

More information

Chapter 2: Operating-System Structures. Operating System Concepts Essentials 8 th Edition

Chapter 2: Operating-System Structures. Operating System Concepts Essentials 8 th Edition Chapter 2: Operating-System Structures Operating System Concepts Essentials 8 th Edition Silberschatz, Galvin and Gagne 2011 Chapter 2: Operating-System Structures Operating System Services User Operating

More information

The failure of Operating Systems,

The failure of Operating Systems, The failure of Operating Systems, and how we can fix it. Glauber Costa Lead Software Engineer August 30th, 2012 Linuxcon Opening Notes I'll be doing Hypervisors vs Containers here. But: 2 2 Opening Notes

More information

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

2 Processes. 2 Processes. 2 Processes. 2.1 The Process Model. 2.1 The Process Model PROCESSES OPERATING SYSTEMS OPERATING SYSTEMS PROCESSES 2 All modern computers often do several things at the same time. A modern operating system sees each software as a process. When a user PC is booted, many processes are secretly

More information

Chapter 2: Operating-System

Chapter 2: Operating-System Chapter 2: Operating-System Structures Chapter 2: Operating-System Structures Operating System Services! User Operating System Interface! System Calls! Types of System Calls! System Programs! Operating

More information

CHAPTER 16 - VIRTUAL MACHINES

CHAPTER 16 - VIRTUAL MACHINES CHAPTER 16 - VIRTUAL MACHINES 1 OBJECTIVES Explore history and benefits of virtual machines. Discuss the various virtual machine technologies. Describe the methods used to implement virtualization. Show

More information

Operating System. Operating System Overview. Structure of a Computer System. Structure of a Computer System. Structure of a Computer System

Operating System. Operating System Overview. Structure of a Computer System. Structure of a Computer System. Structure of a Computer System Overview Chapter 1.5 1.9 A program that controls execution of applications The resource manager An interface between applications and hardware The extended machine 1 2 Structure of a Computer System Structure

More information

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

ECE 7650 Scalable and Secure Internet Services and Architecture ---- A Systems Perspective. Part I: Operating system overview: Memory Management ECE 7650 Scalable and Secure Internet Services and Architecture ---- A Systems Perspective Part I: Operating system overview: Memory Management 1 Hardware background The role of primary memory Program

More information

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

Announcement. Exercise #2 will be out today. Due date is next Monday Announcement Exercise #2 will be out today Due date is next Monday Major OS Developments 2 Evolution of Operating Systems Generations include: Serial Processing Simple Batch Systems Multiprogrammed Batch

More information

Computer Systems II. First Two Major Computer System Evolution Steps

Computer Systems II. First Two Major Computer System Evolution Steps Computer Systems II Introduction to Processes 1 First Two Major Computer System Evolution Steps Led to the idea of multiprogramming (multiple concurrent processes) 2 1 At First (1945 1955) In the beginning,

More information

The Process Abstraction. CMPU 334 Operating Systems Jason Waterman

The Process Abstraction. CMPU 334 Operating Systems Jason Waterman The Process Abstraction CMPU 334 Operating Systems Jason Waterman How to Provide the Illusion of Many CPUs? Goal: run N processes at once even though there are M CPUs N >> M CPU virtualizing The OS can

More information

COMPUTER ARCHITECTURE. Virtualization and Memory Hierarchy

COMPUTER ARCHITECTURE. Virtualization and Memory Hierarchy COMPUTER ARCHITECTURE Virtualization and Memory Hierarchy 2 Contents Virtual memory. Policies and strategies. Page tables. Virtual machines. Requirements of virtual machines and ISA support. Virtual machines:

More information

Operating-System Structures

Operating-System Structures Operating-System Structures System Components Operating System Services System Calls System Programs System Structure System Design and Implementation System Generation 1 Common System Components Process

More information

Chapter 2: Operating-System Structures

Chapter 2: Operating-System Structures Chapter 2: Operating-System Structures Chapter 2: Operating-System Structures Operating System Services User Operating System Interface System Calls (important!) Types of System Calls (important!) System

More information

CISC 7310X. C03: Process. Hui Chen Department of Computer & Information Science CUNY Brooklyn College. 2/15/2018 CUNY Brooklyn College

CISC 7310X. C03: Process. Hui Chen Department of Computer & Information Science CUNY Brooklyn College. 2/15/2018 CUNY Brooklyn College CISC 7310X C03: Process Hui Chen Department of Computer & Information Science CUNY Brooklyn College 2/15/2018 CUNY Brooklyn College 1 Recap & Issues Topics Tools of the trade SCM (e.g., Git), Virtualization

More information

Introduction. CS3026 Operating Systems Lecture 01

Introduction. CS3026 Operating Systems Lecture 01 Introduction CS3026 Operating Systems Lecture 01 One or more CPUs Device controllers (I/O modules) Memory Bus Operating system? Computer System What is an Operating System An Operating System is a program

More information

JSish. Ryan Grasell. June For my senior project, I implemented Professor Keen s JSish spec in C++. JSish

JSish. Ryan Grasell. June For my senior project, I implemented Professor Keen s JSish spec in C++. JSish JSish Ryan Grasell June 2015 1 Introduction For my senior project, I implemented Professor Keen s JSish spec in C++. JSish is a subset of Javascript with support for execution from the command line and

More information

PROCESS MANAGEMENT. Operating Systems 2015 Spring by Euiseong Seo

PROCESS MANAGEMENT. Operating Systems 2015 Spring by Euiseong Seo PROCESS MANAGEMENT Operating Systems 2015 Spring by Euiseong Seo Today s Topics Process Concept Process Scheduling Operations on Processes Interprocess Communication Examples of IPC Systems Communication

More information

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

CPSC 341 OS & Networks. Processes. Dr. Yingwu Zhu CPSC 341 OS & Networks Processes Dr. Yingwu Zhu Process Concept Process a program in execution What is not a process? -- program on a disk A process is an active object, but a program is just a file It

More information

Chapter 11: File System Implementation. Objectives

Chapter 11: File System Implementation. Objectives Chapter 11: File System Implementation Objectives To describe the details of implementing local file systems and directory structures To describe the implementation of remote file systems To discuss block

More information

csci3411: Operating Systems

csci3411: Operating Systems csci3411: Operating Systems Lecture 3: System structure and Processes Gabriel Parmer Some slide material from Silberschatz and West System Structure System Structure How different parts of software 1)

More information

Lecture 3: O/S Organization. plan: O/S organization processes isolation

Lecture 3: O/S Organization. plan: O/S organization processes isolation 6.828 2012 Lecture 3: O/S Organization plan: O/S organization processes isolation topic: overall o/s design what should the main components be? what should the interfaces look like? why have an o/s at

More information

Utilizing Linux Kernel Components in K42 K42 Team modified October 2001

Utilizing Linux Kernel Components in K42 K42 Team modified October 2001 K42 Team modified October 2001 This paper discusses how K42 uses Linux-kernel components to support a wide range of hardware, a full-featured TCP/IP stack and Linux file-systems. An examination of the

More information

Chapter 2: Operating-System Structures

Chapter 2: Operating-System Structures Chapter 2: Operating-System Structures Silberschatz, Galvin and Gagne 2009 Chapter 2: Operating-System Structures Operating System Services User Operating System Interface System Calls Types of System

More information

Lecture 4: Memory Management & The Programming Interface

Lecture 4: Memory Management & The Programming Interface CS 422/522 Design & Implementation of Operating Systems Lecture 4: Memory Management & The Programming Interface Zhong Shao Dept. of Computer Science Yale University Acknowledgement: some slides are taken

More information

What Makes Up the Modern Linux OS?

What Makes Up the Modern Linux OS? White Paper by David Davis, ActualTech Media What Makes Up the Modern Linux OS? In this Paper The History of Linux... 2 The Components that Comprise the Linux Operating System... 3 What Is a Distribution?...

More information

Addresses in the source program are generally symbolic. A compiler will typically bind these symbolic addresses to re-locatable addresses.

Addresses in the source program are generally symbolic. A compiler will typically bind these symbolic addresses to re-locatable addresses. 1 Memory Management Address Binding The normal procedures is to select one of the processes in the input queue and to load that process into memory. As the process executed, it accesses instructions and

More information

Design Overview of the FreeBSD Kernel CIS 657

Design Overview of the FreeBSD Kernel CIS 657 Design Overview of the FreeBSD Kernel CIS 657 Organization of the Kernel Machine-independent 86% of the kernel (80% in 4.4BSD) C code Machine-dependent 14% of kernel Only 0.6% of kernel in assembler (2%

More information

CS 136: Advanced Architecture. Review of Caches

CS 136: Advanced Architecture. Review of Caches 1 / 30 CS 136: Advanced Architecture Review of Caches 2 / 30 Why Caches? Introduction Basic goal: Size of cheapest memory... At speed of most expensive Locality makes it work Temporal locality: If you

More information

CSE506: Operating Systems CSE 506: Operating Systems

CSE506: Operating Systems CSE 506: Operating Systems CSE 506: Operating Systems What Software Expects of the OS What Software Expects of the OS Shell Memory Address Space for Process System Calls System Services Launching Program Executables Shell Gives

More information

Design Overview of the FreeBSD Kernel. Organization of the Kernel. What Code is Machine Independent?

Design Overview of the FreeBSD Kernel. Organization of the Kernel. What Code is Machine Independent? Design Overview of the FreeBSD Kernel CIS 657 Organization of the Kernel Machine-independent 86% of the kernel (80% in 4.4BSD) C C code Machine-dependent 14% of kernel Only 0.6% of kernel in assembler

More information

Chapter 2: Operating-System Structures

Chapter 2: Operating-System Structures Chapter 2: Operating-System Structures 2.1 Silberschatz, Galvin and Gagne 2009 Chapter 2: Operating-System Structures Operating System Services User Operating System Interface System Calls Types of System

More information

Operating System Design

Operating System Design Operating System Design Processes Operations Inter Process Communication (IPC) Neda Nasiriani Fall 2018 1 Process 2 Process Lifecycle 3 What information is needed? If you want to design a scheduler to

More information

64-bit ARM Unikernels on ukvm

64-bit ARM Unikernels on ukvm 64-bit ARM Unikernels on ukvm Wei Chen Senior Software Engineer Tokyo / Open Source Summit Japan 2017 2017-05-31 Thanks to Dan Williams, Martin Lucina, Anil Madhavapeddy and other Solo5

More information

Advanced Operating Systems (CS 202) Scheduling (2)

Advanced Operating Systems (CS 202) Scheduling (2) Advanced Operating Systems (CS 202) Scheduling (2) Lottery Scheduling 2 2 2 Problems with Traditional schedulers Priority systems are ad hoc: highest priority always wins Try to support fair share by adjusting

More information

10 Steps to Virtualization

10 Steps to Virtualization AN INTEL COMPANY 10 Steps to Virtualization WHEN IT MATTERS, IT RUNS ON WIND RIVER EXECUTIVE SUMMARY Virtualization the creation of multiple virtual machines (VMs) on a single piece of hardware, where

More information

Memory Management. Disclaimer: some slides are adopted from book authors slides with permission 1

Memory Management. Disclaimer: some slides are adopted from book authors slides with permission 1 Memory Management Disclaimer: some slides are adopted from book authors slides with permission 1 Demand paging Concepts to Learn 2 Abstraction Virtual Memory (VM) 4GB linear address space for each process

More information

Operating System Concepts

Operating System Concepts Chapter 9: Virtual-Memory Management 9.1 Silberschatz, Galvin and Gagne 2005 Chapter 9: Virtual Memory Background Demand Paging Copy-on-Write Page Replacement Allocation of Frames Thrashing Memory-Mapped

More information

With regard to operating systems the kernel consists of the most frequently used functions in the operating system and it kept in main memory.

With regard to operating systems the kernel consists of the most frequently used functions in the operating system and it kept in main memory. CS 320 Ch 8 Operating Systems An operating system controls execution of applications and acts as an interface between the user and the computer. A typical OS provides the following services: Program Creation

More information

Virtual Memory Outline

Virtual Memory Outline Virtual Memory Outline Background Demand Paging Copy-on-Write Page Replacement Allocation of Frames Thrashing Memory-Mapped Files Allocating Kernel Memory Other Considerations Operating-System Examples

More information

Past: Making physical memory pretty

Past: Making physical memory pretty Past: Making physical memory pretty Physical memory: no protection limited size almost forces contiguous allocation sharing visible to program easy to share data gcc gcc emacs Virtual memory each program

More information

Chapter 3: Processes. Operating System Concepts 9 th Edit9on

Chapter 3: Processes. Operating System Concepts 9 th Edit9on Chapter 3: Processes Operating System Concepts 9 th Edit9on Silberschatz, Galvin and Gagne 2013 Chapter 3: Processes 1. Process Concept 2. Process Scheduling 3. Operations on Processes 4. Interprocess

More information

Operating- System Structures

Operating- System Structures Operating- System Structures 2 CHAPTER Practice Exercises 2.1 What is the purpose of system calls? Answer: System calls allow user-level processes to request services of the operating system. 2.2 What

More information

Chapter 8 & Chapter 9 Main Memory & Virtual Memory

Chapter 8 & Chapter 9 Main Memory & Virtual Memory Chapter 8 & Chapter 9 Main Memory & Virtual Memory 1. Various ways of organizing memory hardware. 2. Memory-management techniques: 1. Paging 2. Segmentation. Introduction Memory consists of a large array

More information

Chapter 2: Operating-System Structures. Chapter 2: Operating-System Structures. Objectives. Operating System Services

Chapter 2: Operating-System Structures. Chapter 2: Operating-System Structures. Objectives. Operating System Services Chapter 2: Operating-System Structures Chapter 2: Operating-System Structures Operating System Services User Operating System Interface System Calls Types of System Calls System Programs Operating System

More information

OS Virtualization. Linux Containers (LXC)

OS Virtualization. Linux Containers (LXC) OS Virtualization Emulate OS-level interface with native interface Lightweight virtual machines No hypervisor, OS provides necessary support Referred to as containers Solaris containers, BSD jails, Linux

More information

MASSACHUSETTS INSTITUTE OF TECHNOLOGY Computer Systems Engineering: Spring Quiz I Solutions

MASSACHUSETTS INSTITUTE OF TECHNOLOGY Computer Systems Engineering: Spring Quiz I Solutions Department of Electrical Engineering and Computer Science MASSACHUSETTS INSTITUTE OF TECHNOLOGY 6.033 Computer Systems Engineering: Spring 2011 Quiz I Solutions There are 10 questions and 12 pages in this

More information

Operating System Review

Operating System Review COP 4225 Advanced Unix Programming Operating System Review Chi Zhang czhang@cs.fiu.edu 1 About the Course Prerequisite: COP 4610 Concepts and Principles Programming System Calls Advanced Topics Internals,

More information

CSC 539: Operating Systems Structure and Design. Spring 2006

CSC 539: Operating Systems Structure and Design. Spring 2006 CSC 539: Operating Systems Structure and Design Spring 2006 Processes and threads process concept process scheduling: state, PCB, process queues, schedulers process operations: create, terminate, wait,

More information

Native POSIX Thread Library (NPTL) CSE 506 Don Porter

Native POSIX Thread Library (NPTL) CSE 506 Don Porter Native POSIX Thread Library (NPTL) CSE 506 Don Porter Logical Diagram Binary Memory Threads Formats Allocators Today s Lecture Scheduling System Calls threads RCU File System Networking Sync User Kernel

More information

Virtualization. ...or how adding another layer of abstraction is changing the world. CIS 399: Unix Skills University of Pennsylvania.

Virtualization. ...or how adding another layer of abstraction is changing the world. CIS 399: Unix Skills University of Pennsylvania. Virtualization...or how adding another layer of abstraction is changing the world. CIS 399: Unix Skills University of Pennsylvania April 6, 2009 (CIS 399 Unix) Virtualization April 6, 2009 1 / 22 What

More information

ò mm_struct represents an address space in kernel ò task represents a thread in the kernel ò A task points to 0 or 1 mm_structs

ò mm_struct represents an address space in kernel ò task represents a thread in the kernel ò A task points to 0 or 1 mm_structs Last time We went through the high-level theory of scheduling algorithms Scheduling Today: View into how Linux makes its scheduling decisions Don Porter CSE 306 Lecture goals Understand low-level building

More information

by Marina Cholakyan, Hyduke Noshadi, Sepehr Sahba and Young Cha

by Marina Cholakyan, Hyduke Noshadi, Sepehr Sahba and Young Cha CS 111 Scribe Notes for 4/11/05 by Marina Cholakyan, Hyduke Noshadi, Sepehr Sahba and Young Cha Processes What is a process? A process is a running instance of a program. The Web browser you're using to

More information

Scheduling. Don Porter CSE 306

Scheduling. Don Porter CSE 306 Scheduling Don Porter CSE 306 Last time ò We went through the high-level theory of scheduling algorithms ò Today: View into how Linux makes its scheduling decisions Lecture goals ò Understand low-level

More information

Chapter 4: Threads. Overview Multithreading Models Thread Libraries Threading Issues Operating System Examples Windows XP Threads Linux Threads

Chapter 4: Threads. Overview Multithreading Models Thread Libraries Threading Issues Operating System Examples Windows XP Threads Linux Threads Chapter 4: Threads Overview Multithreading Models Thread Libraries Threading Issues Operating System Examples Windows XP Threads Linux Threads Chapter 4: Threads Objectives To introduce the notion of a

More information

TDDI04, K. Arvidsson, IDA, Linköpings universitet Operating System Structures. Operating System Structures Overview. Operating System Services

TDDI04, K. Arvidsson, IDA, Linköpings universitet Operating System Structures. Operating System Structures Overview. Operating System Services TDDI04 Concurrent Programming, Operating Systems, and Real-time Operating Systems Operating System Structures [SGG7] Chapter 2 Copyright Notice: The lecture notes are mainly based on Silberschatz s, Galvin

More information

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

Introduction to OS Processes in Unix, Linux, and Windows MOS 2.1 Mahmoud El-Gayyar Introduction to OS Processes in Unix, Linux, and Windows MOS 2.1 Mahmoud El-Gayyar elgayyar@ci.suez.edu.eg Mahmoud El-Gayyar / Introduction to OS 1 Processes in Unix, Linux, and Windows Unix pre-empted

More information