CS5460: Operating Systems

Similar documents
The UtePC/Yalnix Memory System

CS 5460: Operating Systems Fall 2004 Handout 3. The Yalnix Kernel

Anne Bracy CS 3410 Computer Science Cornell University

Processes. Dr. Yingwu Zhu

Lec 22: Interrupts. Kavita Bala CS 3410, Fall 2008 Computer Science Cornell University. Announcements

Precept 2: Non-preemptive Scheduler. COS 318: Fall 2018

Anne Bracy CS 3410 Computer Science Cornell University

Syscalls, exceptions, and interrupts, oh my!

IT 540 Operating Systems ECE519 Advanced Operating Systems

Dr. D. M. Akbar Hussain DE5 Department of Electronic Systems

Hakim Weatherspoon CS 3410 Computer Science Cornell University

Operating System Control Structures

Lecture 4: Mechanism of process execution. Mythili Vutukuru IIT Bombay

Process Description and Control. Chapter 3

message passing model

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

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

3.1 Introduction. Computers perform operations concurrently

Virtual Memory. 1 Administrivia. Tom Kelliher, CS 240. May. 1, Announcements. Homework, toolboxes due Friday. Assignment.

Process Description and Control. Chapter 3

Process. Discussion session 3 1/30/2016

Chapter 3: Important Concepts (3/29/2015)

Problem Set 2. CS347: Operating Systems

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

Chapter 3 Process Description and Control

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

Process Description and Control. Chapter 3

CS 322 Operating Systems Practice Midterm Questions

Today s Topics. u Thread implementation. l Non-preemptive versus preemptive threads. l Kernel vs. user threads

Introduction to the Process David E. Culler CS162 Operating Systems and Systems Programming Lecture 2 Sept 3, 2014

Process Description and Control

CS153: Process. Chengyu Song. Slides modified from Harsha Madhyvasta, Nael Abu-Ghazaleh, and Zhiyun Qian

THE PROCESS ABSTRACTION. CS124 Operating Systems Winter , Lecture 7

CS3600 SYSTEMS AND NETWORKS

Chapter 3: Processes. Operating System Concepts 8 th Edition,

Processes. CS439: Principles of Computer Systems January 30, 2019

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

Process Concept. Minsoo Ryu. Real-Time Computing and Communications Lab. Hanyang University.

Operating System Design

Process Description and Control

OPERATING SYSTEM OVERVIEW

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

Process Description and Control. Major Requirements of an Operating System

Major Requirements of an Operating System Process Description and Control

Processes and More. CSCI 315 Operating Systems Design Department of Computer Science

CS 537 Lecture 2 - Processes

Processes. Process Concept

Roadmap. Tevfik Ko!ar. CSC Operating Systems Fall Lecture - III Processes. Louisiana State University. Processes. September 1 st, 2009

What s An OS? Cyclic Executive. Interrupts. Advantages Simple implementation Low overhead Very predictable

ENGR 3950U / CSCI 3020U Midterm Exam SOLUTIONS, Fall 2012 SOLUTIONS

PROCESSES. Jo, Heeseung

Processes. Jo, Heeseung

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

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

Today s Topics. u Thread implementation. l Non-preemptive versus preemptive threads. l Kernel vs. user threads

Process Description and Control

Hardware OS & OS- Application interface

CS Week 8 Lab Assignment 3. Teaching Assistant Henrique Potter

CS 550 Operating Systems Spring Interrupt

Announcements Processes: Part II. Operating Systems. Autumn CS4023

Inf2C - Computer Systems Lecture 16 Exceptions and Processor Management

Lecture 3: Processes. CMPUT 379, Section A1, Winter 2014 January 13, 15 and 17

Process Description and Control

Protection and System Calls. Otto J. Anshus

Processes. CS439: Principles of Computer Systems January 24, 2018

Operating Systems. Computer Science & Information Technology (CS) Rank under AIR 100

CS 31: Intro to Systems Processes. Kevin Webb Swarthmore College March 31, 2016

Chapter 3 Process Description and Control

Review: Hardware user/kernel boundary

Topics: Virtual Memory (SGG, Chapter 09) CS 3733 Operating Systems

Insight into Program execution

The Kernel Abstraction

CS 33. Architecture and the OS. CS33 Intro to Computer Systems XIX 1 Copyright 2018 Thomas W. Doeppner. All rights reserved.

Operating Systems 9/6/ SIGINT Terminate Interrupt from keyboard (ctl-c) 9 SIGKILL Terminate Kill program (cannot override or ignore)

OS 1 st Exam Name Solution St # (Q1) (19 points) True/False. Circle the appropriate choice (there are no trick questions).

Module 1. Introduction:

CS 537 Lecture 2 Computer Architecture and Operating Systems. OS Tasks

Processes (Intro) Yannis Smaragdakis, U. Athens

Process! Process Creation / Termination! Process Transitions in" the Two-State Process Model! A Two-State Process Model!

CS510 Operating System Foundations. Jonathan Walpole

CS533 Concepts of Operating Systems. Jonathan Walpole

The Kernel Abstraction. Chapter 2 OSPP Part I

Processes & Threads. Recap of the Last Class. Layered Structure. Virtual Machines. CS 256/456 Dept. of Computer Science, University of Rochester

! The Process Control Block (PCB) " is included in the context,

Computer architecture. A simplified model

Processes and Threads

Virtual Memory Management

1 PROCESSES PROCESS CONCEPT The Process Process State Process Control Block 5

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

Operating Systems. Introduction & Overview. Outline for today s lecture. Administrivia. ITS 225: Operating Systems. Lecture 1

Control Abstraction. Hwansoo Han

Yielding, General Switching. November Winter Term 2008/2009 Gerd Liefländer Universität Karlsruhe (TH), System Architecture Group

Processes. CS3026 Operating Systems Lecture 05

Inter-Process Communication and Synchronization of Processes, Threads and Tasks: Lesson-1: PROCESS

Using kgdb and the kgdb Internals

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

CSE 509: Computer Security

Linux Operating System

CS370 Operating Systems

Ricardo Rocha. Department of Computer Science Faculty of Sciences University of Porto

Transcription:

CS5460: Operating Systems -- some hints

Goal Support virtual memory Load and execute multiple independent user-level program

KernelStart-- boot Yalnix 1. Initialize memory 2. Initialize IO 3. Set up Trap Handler table 4. Initialize PCB data structures 5. Call 'LoadProgram' to load program into memory, initialize processes 6. Context switch to some process and run

Yalnix Virtual Memory Organization Paged memory scheme using page tables Two regions (two modes) Initial states Region0 -- kernel VMEM_0_LIMIT read/write Kernel stack VMEM_1_LIMIT Region1 -- user VMEM_0_SIZE Invalid VMEM_1_SIZE Invalid read/write read/exec VMEM_0_BASE Data Segment Text/code Segment VMEM_1_BASE

Yalnix Physical Memory Organization PMEM_BASE == VEME_0_BASE! Initial states Need manage free frames Kernel stack peme_size PMEM_0_BASE Data Segment Text/code Segment sbrk(0) & data_start

Translate Addresses into Page Numbers Page numbers in regions Why? Page table sizes How? VMEM_0_SIZE >> PAGESHIFT Page number and Page index in the kernel stack Fixed size Every process has one kernel stack Why? A Process need loads its kernel stack pages into the kernel page table upon context switching How?» Kernel stack page number (KERNEL_STACK_MAXSIZE>>PAGESHIFT)» Kernel stack start-page index (KERNEL_STACK_BASE>>PAGESHIFT)» More: allocate physical frames for kernel stack pages during the PCB construction

Find the boundaries Macros: UP_TO_PAGE(x), DOWN_TO_PAGE(x) Round the address x to the page boundary. If x is on a page boundary, it returns x. Example: last data page Index UP_TO_PAGE(sbrk(0))>> PAGESHIFT - 1

Memory Initialization Page tables are defined in region 0 Things to consider 1. Initialize the page table for region 0 Code (Text) pages, data pages, stack pages set related register(reg_ptbr0, REG_PTLR0) 2. Initialise the page table for the current user process (optional) (REG_PTBR1, REG_PTLR1) 3. Initialize free frames pool Stack, list, queue... 4. Enable virtual memory REG_VM_ENABLE, REG_TLB_FLUSH

I/O Initialization Kernel must buffer the I/O data I/O buffers cannot have fixed size buffers are not restricted by the available memory Things to consider Read/write(may not need) buffers for each terminal Read/write waiting queues for each terminal Synchronization mechanism for the waiting queues

Set up Trap Handler Table You already know Or you are in trouble

PCB Initialization What should be kept? things to consider: Pid Status Timeout (used for Delay system call) Kernel context User context User Page table Kernel stack frame numbers User break Pointers to previous, next PCB (link PCBs as a bi-direction list) PCB queues

Template: load.templates Loading Programs Read the instructions and customize it for your use What could happen when loading a program? Find out the code segment, data segment, stack sizes allocates the pages for user text, data and stack segments Fill the user page table and make it effective Copy data into allocated frames Update pc, sp, brk, data_start Restore the original user page table

Context Switching Where and when? End of the KernelStart() The Clock Trap Handler Anywhere you need. Kernel Context Switching Where you can copy the kernel context KernelContext *MyKCS(KernelContext *, void *, void *) What could happen in your call-back?» Load and flush kernel stack pages» Save current user context to the PCB to be switched to» More User Context Switching Save anything you need Load and flush the user page table Update PCB queue Update the current user context

SetKenelBrk() Allocate or deallocate memory in kennel space Check the same page Check the available virtual and physical memory Allocate frames and set the appropriate page entries Release frames and update page entries on deallocation Report error on special cases Out of virtual memory Out of physical memory

System Calls System call is triggered via TRAP_KERNEL Switch (conext->code) case... Get parameters from UserContext->regs[] Return value set to UserContext->regs[0] In project 3, we need to implement TtyRead TtyWrite Brk Exit Delay

TtyRead/TtyWrite & Tty Trap Handlers Things to consider Get the tty id from UserContext->Code Check the validity of any data buffer! Send in the unit of TERMINAL_MAX_LINE, receive is restricted by the parameter len Copy data to or from the kernel memory space Hardware operations: TtyReceive(), TtyTransmit() Producer and consumer The receive trap handler and tty read system call Tty write system call and TtyTransmit() Synchronization

Things to consider Check address validity Brk» You need ubrk: where is it stored?» You need user stack base Other things noted in SetKernelBrk()

Delay Delay and Exit You may need a delay queue for this Check the time very clock interrupt Exit Release resources A special context switching scenario

Kernel break System clock Process id counter PCB queues IO buffers Global variables Free memory page pool...

Testing Write some small programs Compile it with the help of Makefile.usr Run the program Yalnix prog1 prog2...

Q &A