Discussion Week 5 TA: Kyle Dewey. Overview HW 3.10 and 6.2 review Binary formats System call execution in NACHOS Memory management in NACHOS I/O in NACHOS.

Slides:



Advertisements
Similar presentations
Operating Systems Components of OS
Advertisements

More on Processes Chapter 3. Process image _the physical representation of a process in the OS _an address space consisting of code, data and stack segments.
Chapter 3 Process Description and Control
Slide 2-1 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 2 Using the Operating System 2.
Discussion Week 7 TA: Kyle Dewey. Overview Midterm debriefing Virtual memory Virtual Filesystems / Disk I/O Project #3.
CSCC69: Operating Systems
Exceptional Control Flow Processes Today. Control Flow Processors do only one thing: From startup to shutdown, a CPU simply reads and executes (interprets)
Operating Systems Lecture 10 Issues in Paging and Virtual Memory Adapted from Operating Systems Lecture Notes, Copyright 1997 Martin C. Rinard. Zhiqing.
Discussion Week 4 TA: Kyle Dewey. Overview Project #1 debriefing System calls Project #2.
Chapter 6 Limited Direct Execution
OS Fall ’ 02 Introduction Operating Systems Fall 2002.
Architectural Support for Operating Systems. Announcements Most office hours are finalized Assignments up every Wednesday, due next week CS 415 section.
1 CS 333 Introduction to Operating Systems Class 2 – OS-Related Hardware & Software The Process Concept Jonathan Walpole Computer Science Portland State.
Home: Phones OFF Please Unix Kernel Parminder Singh Kang Home:
3.5 Interprocess Communication
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.
Computer System Organization S H Srinivasan
CSSE Operating Systems
1 Process Description and Control Chapter 3 = Why process? = What is a process? = How to represent processes? = How to control processes?
7/3/20151 Announcement (No deadline extension for the rest of quarter) Project 2 final deadline is Tuesday midnight May 19 Project 0 resubmission for autograding.
Process Description and Control A process is sometimes called a task, it is a program in execution.
OS Spring’04 Introduction Operating Systems Spring 2004.
Process. Process Concept Process – a program in execution Textbook uses the terms job and process almost interchangeably A process includes: – program.
I/O Tanenbaum, ch. 5 p. 329 – 427 Silberschatz, ch. 13 p
CSE 451: Operating Systems Autumn 2013 Module 6 Review of Processes, Kernel Threads, User-Level Threads Ed Lazowska 570 Allen.
Discussion Week 3 TA: Kyle Dewey. Overview Concurrency overview Synchronization primitives Semaphores Locks Conditions Project #1.
Welcome to the World of Nachos CPS 110 Spring 2004 Discussion Session 1.
Protection and the Kernel: Mode, Space, and Context.
OPERATING SYSTEM OVERVIEW. Contents Basic hardware elements.
Chapter 4: Threads. 4.2CSCI 380 Operating Systems Chapter 4: Threads Overview Multithreading Models Threading Issues Pthreads Windows XP Threads Linux.
CS1550 Assignment 5 Multiprogramming Implementation notes Matt Craven.
Composition and Evolution of Operating Systems Introduction to Operating Systems: Module 2.
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.
The Structure of Processes. What is a Process? an instance of running program Program vs process(task) Program : just a passive collection of instructions.
The Structure of Processes (Chap 6 in the book “The Design of the UNIX Operating System”)
Lecture 3 Process Concepts. What is a Process? A process is the dynamic execution context of an executing program. Several processes may run concurrently,
Operating Systems Lecture 7 OS Potpourri Adapted from Operating Systems Lecture Notes, Copyright 1997 Martin C. Rinard. Zhiqing Liu School of Software.
Hardware process When the computer is powered up, it begins to execute fetch-execute cycle for the program that is stored in memory at the boot strap entry.
1 CSE 451 Section 2: Interrupts, Syscalls, Virtual Machines, and Project 1.
© 2004, D. J. Foreman 1 Implementing Processes and Threads.
Processes Questions answered in this lecture: What is a process? How does the dispatcher context-switch between processes? How does the OS create a new.
Interrupt driven I/O. MIPS RISC Exception Mechanism The processor operates in The processor operates in user mode user mode kernel mode kernel mode Access.
Silberschatz, Galvin and Gagne  Operating System Concepts Process Concept An operating system executes a variety of programs:  Batch system.
We will focus on operating system concepts What does it do? How is it implemented? Apply to Windows, Linux, Unix, Solaris, Mac OS X. Will discuss differences.
1 Computer Systems II Introduction to Processes. 2 First Two Major Computer System Evolution Steps Led to the idea of multiprogramming (multiple concurrent.
Discussion Week 2 TA: Kyle Dewey. Overview Concurrency Process level Thread level MIPS - switch.s Project #1.
Concurrency, Processes, and System calls Benefits and issues of concurrency The basic concept of process System calls.
Processes, Threads, and Process States. Programs and Processes  Program: an executable file (before/after compilation)  Process: an instance of a program.
Nachos Lecture 2 Xiaorui Sun. Phase 2 You have got one machine (machine package) You have to implements the incomplete OS (userprog package) Run programs.
Hardware process When the computer is powered up, it begins to execute fetch-execute cycle for the program that is stored in memory at the boot strap entry.
Interrupt driven I/O Computer Organization and Assembly Language: Module 12.
What is a Process ? A program in execution.
Direct memory access. IO Command includes: buffer address buffer length read or write dada position in disk When IO complete, DMA sends an interrupt request.
Interrupts and Exception Handling. Execution We are quite aware of the Fetch, Execute process of the control unit of the CPU –Fetch and instruction as.
Chapter 6 Limited Direct Execution Chien-Chung Shen CIS/UD
Of Privilege, Traps, Interrupts & Exceptions Prof. Sirer CS 316 Cornell University.
A process is a program in execution A running system consists of multiple processes – OS processes Processes started by the OS to do “system things” –
Exceptional Control Flow
Processes and threads.
Protection of System Resources
KERNEL ARCHITECTURE.
Exceptional Control Flow: System Calls, Page Faults etc.
Structure of Processes
CSE 451: Operating Systems Spring 2012 Module 6 Review of Processes, Kernel Threads, User-Level Threads Ed Lazowska 570 Allen.
Introduction to Operating Systems
Process Control B.Ramamurthy 2/22/2019 B.Ramamurthy.
Unix Process Control B.Ramamurthy 4/11/2019 B.Ramamurthy.
CS510 Operating System Foundations
Presentation transcript:

Discussion Week 5 TA: Kyle Dewey

Overview HW 3.10 and 6.2 review Binary formats System call execution in NACHOS Memory management in NACHOS I/O in NACHOS

Homework 3.10 “Identify the values of pid at lines A, B, C, and D. Assume that the actual pids of the parent and child are 2600 and 2603, respectively.”

Homework 6.2 The Cigarette-Smokers Problem Agent Match Smoker Paper Smoker Tobacco Smoker Table (holds two of three items)

Problem Specifics Agent places two items Smoker with remaining item grabs the two and smokes The process repeats

Java Implementation

Binary Formats

NOFF NACHOS Object File Format Magic Number (0xBADFAD) Code (Text) Initialized Data (Data) Uninitialized Data (BSS)

Why Bother? CPU sees only a stream of instructions All gets loaded into memory anyway

Advantage Tells OS roughly how portions will be used Optimizations possible Share (reentrant) code and constant data Prevent execution of non-code regions

System Calls Revisited

System Call Execution read() User Space Kernel Space read() readFromDisk( ) read()

User -> Kernel Problem: kernel space and user space are enforced by hardware Hardware must be informed of jump

Solution? Instruction to specify the level By necessity, it is privileged Need kernel space to tell the system we’re in kernel space - catch 22

Existing Machinery Interrupts are serviced by the kernel Generated from other devices, often I/O Preempt all else and enter the kernel The routines that service interrupts are called “interrupt service routines” - ISRs

Interrupts Hard Drive ISR 1 ISR 2 ISR 3 Int 1 Memory CPU

Using Interrupts Trigger a “software interrupt” Kernel mode entered synchronously Parameters can be passed in registers, in a specific memory location, etc. Note that the actual mechanism and lingo is hardware dependent

MIPS System Calls MIPS has the “syscall” instruction Processor throws a system call exception, triggering the OS’ system call service routine By convention, the syscall ID is in $v0, and arguments are passed in $a0 and $a1

MIPS System Calls Assume we want the system call with ID 5 This call takes no arguments addi $v0, $zero, 5 syscall CPU Syscall ISR Syscall 5 Handler

code/userprog/ exception.cc code/userprog/ syscall.h code/test/star t.s

Memory Management

Project #2 Memory Physical = virtual (until Project #3) Must using paging Need to allocate and free pages as requested

NACHOS Memory Does not have much 128 byte pages 32 pages total 8 pages for each process’ stack + data + code Simple bitmap is sufficient to record what is and is not used

Contiguous Memory Since physical = virtual, served memory requests must be contiguous I.e. if a process requests 5 pages, they must be contiguous *Could* do compaction, but this is a terrible idea

Fork() Example Used - P1 Free Free Free Used - P2 Used - P1 Free Free Used - P2 Used - P3 P1 fork() s P3 Memory by page

Exit() Example Used - P1 Free Free Used - P2 Used - P3 P2 exit() s Memory by page Used - P1 Free Free Used - P3 Free

Getting Pages Memory is available through: machine->mainMemory Merely array of 1 byte characters Need to split into pages on your own

Memory and Concurrency Multiple processes may request pages at the same time Only one may get any given page Synchronization primitives from Project #1 will have to be used Make sure they work correctly!

I/O Syscalls

NACHOS Disk Do not need to worry about this until Project 3 I/O syscalls for Project 2 utilize Linux’s existing syscalls for file I/O directly

I/O Syscalls Actually implement Read() and Write(), NOT readAt() and writeAt() readAt() and writeAt() ’s provided implementations are sufficient to implement Read() and Write()

Files and Concurrency Process A prints “Hello world!” Process B prints “Goodbye cruel world!” Hello woGoodbye crld! ruel world!

Files and Concurrency Determining what needs to be locked may be difficult May have separate things that need locking May need multiple locks for distinct resources Concurrent reads are OK, but not concurrent writes

Open File Semantics Semantics of Fork() are that child processes inherit open files Read() and Write() can only manipulate open files If a process will not close its files upon Exit(), then the OS must do so

Open Files Which files are opened must be recorded in the PCB This allows for all aforementioned behaviors Also allows for an offset for subsequent Read() and Write() requests

Console Read() and Write() may also manipulate the console Console is not opened or closed Constants specifying console usage are in syscall.h

Caveats The given code is really getting buggy Provided code is also getting really ugly

How-To Implement Project #2 has a step-by-step implementation guide at /homework_2guide.html /homework_2guide.html Please read carefully