Midterm Exam CPS 210: Operating Systems Spring 2013

Similar documents
(In columns, of course.)

CPS 310 first midterm exam, 2/26/2014

CPS 310 first midterm exam, 10/6/2014

Operating Systems Comprehensive Exam. Spring Student ID # 3/16/2006

Unix Processes. What is a Process?

Design Overview of the FreeBSD Kernel CIS 657

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

Operating System Labs. Yuanbin Wu

Process Concepts. CSC400 - Operating Systems. 3. Process Concepts. J. Sumey

Operating Systems Comprehensive Exam. Spring Student ID # 3/20/2013

CSC209 Review. Yeah! We made it!

PROCESS MANAGEMENT. Operating Systems 2015 Spring by Euiseong Seo

Process Time. Steven M. Bellovin January 25,

CSC209: Software tools. Unix files and directories permissions utilities/commands Shell programming quoting wild cards files

CSC209: Software tools. Unix files and directories permissions utilities/commands Shell programming quoting wild cards files. Compiler vs.

COP4342 UNIX Tools Assignment #3: A Simple Unix Shell. Instructor: Dr. Robert Van Engelen Teaching Assistant: Imran Chowdhury Spring 2018

Processes. Dr. Yingwu Zhu

CPS 310 midterm exam #1, 2/19/2018

Lab 1: Dynamic Memory: Heap Manager

3. Process Management in xv6

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

Operating Systems. Review ENCE 360

(MCQZ-CS604 Operating Systems)

Your name please: NetID:

CS 111. Operating Systems Peter Reiher

CS 326: Operating Systems. Process Execution. Lecture 5

PROCESS CONTROL: PROCESS CREATION: UNIT-VI PROCESS CONTROL III-II R

Operating Systems Comprehensive Exam. Spring Student ID # 2/17/2011

REVIEW OF COMMONLY USED DATA STRUCTURES IN OS

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

UNIX Kernel. UNIX History

Noorul Islam College Of Engineering, Kumaracoil MCA Degree Model Examination (October 2007) 5 th Semester MC1642 UNIX Internals 2 mark Questions

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

SOFTWARE ARCHITECTURE 3. SHELL

PROCESS CONTROL BLOCK TWO-STATE MODEL (CONT D)

CSE473/Spring st Midterm Exam Tuesday, February 19, 2007 Professor Trent Jaeger

Assignment 1. Teaching Assistant: Michalis Pachilakis (

Processes COMPSCI 386

Process management. What s in a process? What is a process? The OS s process namespace. A process s address space (idealized)

CPS 310 midterm exam #2, 4/10/2017

CS61 Scribe Notes Date: Topic: Fork, Advanced Virtual Memory. Scribes: Mitchel Cole Emily Lawton Jefferson Lee Wentao Xu

Mid Term from Feb-2005 to Nov 2012 CS604- Operating System

The Process Abstraction. CMPU 334 Operating Systems Jason Waterman

CSE506: Operating Systems CSE 506: Operating Systems

PROCESSES. Jo, Heeseung

Processes. Jo, Heeseung

ESE 333 Real-Time Operating Systems 2 What is an operating system? Two views: 1. Top-down view: Extended machine ffl Covers the details of the hardwar

CSE506: Operating Systems CSE 506: Operating Systems

PROCESS STATES AND TRANSITIONS:

Chap 4, 5: Process. Dongkun Shin, SKKU

Processes. CS3026 Operating Systems Lecture 05

CSE 451: Operating Systems Winter Module 4 Processes. Mark Zbikowski Allen Center 476

The Classical OS Model in Unix

System Programming. Introduction to Unix

Process Management! Goals of this Lecture!

HW 1: Shell. Contents CS 162. Due: September 18, Getting started 2. 2 Add support for cd and pwd 2. 3 Program execution 2. 4 Path resolution 3

CSci 4061 Introduction to Operating Systems. Processes in C/Unix

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

ADVANCED OPERATING SYSTEMS

Operating Systemss and Multicore Programming (1DT089)

The Kernel. wants to be your friend

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

Processes & Threads. (Chapter 3) CS 4410 Operating Systems. [R. Agarwal, L. Alvisi, A. Bracy, M. George, E. Sirer, R. Van Renesse]

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

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

* What are the different states for a task in an OS?

INSTITUTE OF AERONAUTICAL ENGINEERING (Autonomous) Dundigal, Hyderabad

CSE 410: Computer Systems Spring Processes. John Zahorjan Allen Center 534

The Kernel Abstraction. Chapter 2 OSPP Part I

Processes Prof. James L. Frankel Harvard University. Version of 6:16 PM 10-Feb-2017 Copyright 2017, 2015 James L. Frankel. All rights reserved.

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

Computer Science 330 Operating Systems Siena College Spring Lab 5: Unix Systems Programming Due: 4:00 PM, Wednesday, February 29, 2012

Creating a Shell or Command Interperter Program CSCI411 Lab

INSTITUTE OF AERONAUTICAL ENGINEERING (Autonomous) Dundigal, Hyderabad

ECE 598 Advanced Operating Systems Lecture 23

CS 111. Operating Systems Peter Reiher

Exam Guide COMPSCI 386

CPS 310 midterm exam #1, 2/19/2016

Advanced Unix Concepts. Satyajit Rai

Distributed Systems Operation System Support

CS 322 Operating Systems Practice Midterm Questions

Linux shell scripting Getting started *

OS COMPONENTS OVERVIEW OF UNIX FILE I/O. CS124 Operating Systems Fall , Lecture 2

Windows architecture. user. mode. Env. subsystems. Executive. Device drivers Kernel. kernel. mode HAL. Hardware. Process B. Process C.

hardware interrupts software interrupts

Singularity Part 2. Jeff Chase

Project 2: Shell with History1

Confinement (Running Untrusted Programs)

CS 333 Introduction to Operating Systems Class 2 OS-Related Hardware & Software The Process Concept

University of Ottawa School of Information Technology and Engineering

A process. the stack

3.1 Introduction. Computers perform operations concurrently

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

A2 Design Considerations. CS161, Spring

Pebbles Kernel Specification September 26, 2004

CS24: INTRODUCTION TO COMPUTING SYSTEMS. Spring 2018 Lecture 18

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

www nfsd emacs lpr Process Management CS 537 Lecture 4: Processes Example OS in operation Why Processes? Simplicity + Speed

CSC 4320 Test 1 Spring 2017

Process Management 1

Transcription:

Your name: Sign for your honor: Midterm Exam CPS 210: Operating Systems Spring 2013 The last page of this exam is a list of terms used in this class, and whose meanings you should know. You may detach that page. You are asked to answer the questions below, using only the terms on that list. Choose the terms that apply, and only the terms that apply. You can add other words on the side if needed to clarify, but we might ignore them. Part 1. Shell games These examples depict exchanges with a standard shell via a command line with prompt. Explain what happens in each case as best you can using only terms from the list. Order matters. Note: cat is the standard Unix program whose default behavior is to read from stdin and write to stdout. 7 points each, 50 points total. All Part 1 examples: parent shell trap kernel fork child process exec executable program exit Foreground cases: parent wait Optional: program process group tty inheritance kernel mode 1. cat <ctrl-c> tty read block tty signal kill process group exit OK: interrupt ( sigint ) 2. cat scratch& argument open error background exit status [1] 23746 processid optional: child exit signal wait cat: scratch: No such file or directory [1]+ Exit 1 cat scratch 3. cat >/usr/bin/sudo redirect stdout open error exit guard authorization /usr/bin/sudo: Permission denied subject process label userid object write executable file setuid bit root reference monitor 4. login login executable setuid bit root process (authentication) setuid userid login: chase fork exec shell label userid Password: Last login: Sun Feb 17 17:57:19 on ttys006

5. cc -o prog prog.c;./prog Segmentation fault write executable file fork child process exec executable fault kill signal exit 6. notfound sh: notfound: command not found exec error exit environment variable (path) current directory 7. cat cat pipe, fork*2, dup*2, close*4, exec*2, stdin, stdout tty stdin read block, pipe stdin read block Extra credit: How do these cats know when to exit? read EOF, pipe close, reference count, parent close pipe Or signal/kill 8. Extra credit: What does your browser do when you use websubmit to submit the lab? socket connect port login socket connect port reference monitor guard subject userid read file current directory write socket close exit Part 2. How, what, and why Answer each question as best you can using only terms from the list. Order matters. These questions generally apply to the idealized C/Unix environment considered in this class. 8 points each, 50 points total. 9. How does a parent program initialize a child process? open dup close environment variable argument process group tty exec 10. How does the kernel know the userid of your shell? initd fork exec login executable setuid bit root read userid tty guard setuid label inheritance fork exec shell 11. Why does the Chrome browser use a process for each tab? process thread isolation process sandbox virtual address space memory fragmentation process exit virtual memory

12. What does a ready thread do while it is waiting for a core to run on? suspend (nothing) register context memory 13. What does a thread do while it is waiting for a mutex to become free? Block (or) spin (in) acquire (until) release wakeup 14. How does the machine notify the kernel of an arriving network packet? interrupt write memory address Part 3. True or false Answer these questions as true or false. Please extend your answer with terms from the list, e.g., to explain how something can happen, or what prevents it. 8 points each, 40 points total. 15. System calls generally behave like procedure calls: they execute for a time and then return to the caller. True but: exec exit (never return) fork (returns twice) 16. This C program can take over the computer: int main() {while(1);} [Infinite loop] False. clock tick interrupt suspend tty kill signal exit 17. A user process can halt (shut down) the computer. False (not directly): machine kernel mode protection domain isolation True (via a privileged command): invoke executable program setuid bit root trap kernel mode 18. A thread can store into the stack of another thread. True: thread stack process virtual address space protection domain 19. A thread can store into a free heap block. True: heap process virtual address space protection domain Part 4. That heap manager For these questions you can answer in any kind of English and/or pseudocode as long as its meaning is clear. You are not restricted to the terms of the list. 20 points each, 60 total. 20. CS:APP says: "applications that do intensive manipulation of graphs will often use the standard [heap] allocator to acquire a large block of virtual memory, and then use an applicationspecific allocator to manage the memory within that block as the nodes of the graph are created and destroyed." Explain what benefits this approach might offer for this kind of application.

If a heap manager knows the sizes for malloc calls then it can manage pools of memory for specific object sizes. It allocates and recycles heap blocks for exactly those sizes. The advantage is that this can virtually eliminate external and internal memory fragmentation, yielding more efficient use of memory. A good technique is to allocate exactly the requested size (plus padding for alignment). Recycle objects on a separate free list for each size. For example, applications that manipulate very large graphs are likely to use a common struct definition (or a small set of struct definitions) for each node in the graph. The heap blocks for every node in the graph are the same size, or chosen from a small set of sizes. 21. CS:APP says: the [heap] allocator cannot make any assumptions about the ordering of allocate [malloc] and free requests. For example, the allocator cannot assume that...matching allocate and free requests are nested." Here is a definition of "nested": for every pair of allocated heap blocks X and Y, if the program allocates X before Y, then it frees Y before X. Outline briefly how you might simplify your heap manager for that case. The question describes a stack. For a stack we can allocate exactly the size requested for each malloc (plus padding for alignment) by pushing a new block at the top of the stack. The target of any call to free is at the top of the stack, so we only need to pop it off. In this case, malloc/free reduce to pointer arithmetic operations to grow and shrink the stack by the requested size. Splitting and coalescing occur as a side effect of these operations. 22. One challenge for your heap manager is that a program might incorrectly pass an address to free() that was never allocated, e.g., that was never the return value of a malloc() call. We saw in class that a standard heap manager can detect this error. Outline briefly how you might extend your heap manager to detect this error. The answer I expected was to store a magic number (e.g., 0xdeadbeef) in each heap block descriptor (metadata_t). For any given pointer passed to free, the magic number should reside at a fixed offset behind the pointer, i.e., at addresses lower than the start of the heap block. The magic number is unlikely to be present unless the pointer references a valid heap block. Some students said to keep a list or hash table of allocated heap blocks. That works too. A hash table is obviously preferred. In general, for all of these questions, I accepted almost any answer that made sense and established clearly that you understand how a heap manager works.

The List of Approved Terms Nouns: machine, core, memory, program, module, code, executable, object file, directory, current directory, library, segment, section, VM (virtual address space or virtual memory), thread, process, stack, heap, context, register, parent, child, kernel, mode, mode bit, setuid, setuid bit, root, handler, event, foreground, background, exit status, clock tick, environment variable, argument, scheduler, schedule, subject, object, guard, eof, tty, timeslice, stdin, stdout, process group, job, identity, attribute, malware, sandbox, init, inetd, shell, channel, port, principal, capability, connection, race, worker, stub, error, userid, processid, dangling reference, reference count, address. Verbs: wakeup, spin, sbrk, fork, exec*, exit, wait*, dup*, open, bind, listen, connect, accept, read, write, malloc/free, dispatch, suspend, kill* (send signal), close, poll, chdir, invoke, return, acquire, release. These words can be verbs or nouns: trap, fault, interrupt, block, pipe, socket, upcall, signal, load/store, login, label. Conditions and concepts: fragmentation, isolation, authorization, inheritance, threadsafe, redirection, protection domain, reference monitor