OS Structure & Processes1 Vivek Pai COS 318 September 19, 2002.

Slides:



Advertisements
Similar presentations
Programs in Memory Bryce Boe 2012/08/29 CS32, Summer 2012 B.
Advertisements

Copyright © 2000, Daniel W. Lewis. All Rights Reserved. CHAPTER 9 MEMORY MANAGEMENT.
Various languages….  Could affect performance  Could affect reliability  Could affect language choice.
User-Level Memory Management in Linux Programming
Week 7 - Friday.  What did we talk about last time?  Allocating 2D arrays.
Memory allocation CSE 2451 Matt Boggus. sizeof The sizeof unary operator will return the number of bytes reserved for a variable or data type. Determine:
CS 241 Section Week #5 2/23/12. 2 Topics This Section MP4 overview Function Pointers Pthreads File I/O.
Ways to read data from disk to memory Tan Li. read, write read, write -- low level file access, it's an operation between two file discriptors. SYNOPSIS.
Today’s topic: –File operations –I/O redirection –Inter-process communication through pipes.
COSC 120 Computer Programming
Memory Management Norman White Stern School of Business.
Dynamic Memory Allocation in C++. Memory Segments in C++ Memory is divided in certain segments – Code Segment Stores application code – Data Segment Holds.
Chapter 8.3: Memory Management
Introduction to Kernel
CS 300 – Lecture 23 Intro to Computer Architecture / Assembly Language Virtual Memory Pipelining.
L18 – Memory Hierarchy 1 Comp 411 – Fall /30/2009 Memory Hierarchy Memory Flavors Principle of Locality Program Traces Memory Hierarchies Associativity.
Unix Process Environment. main Function A C program starts execution with a function called main. The prototype for the main function is: int main (int.
OPERATING SYSTEMS Introduction
7/13/20151 Topic 3: Run-Time Environment Memory Model Activation Record Call Convention Storage Allocation Runtime Stack and Heap Garbage Collection.
15213 C Primer 17 September Outline Overview comparison of C and Java Good evening Preprocessor Command line arguments Arrays and structures Pointers.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Chapter 2: Operating-System Structures Modified from the text book.
Operating Systems Concepts 1. A Computer Model An operating system has to deal with the fact that a computer is made up of a CPU, random access memory.
ITEC 320 Lecture 26 C++ Introduction. Introduction Qualification s Ten years of C++ development (albeit not fulltime) Written somewhere between kloc.
POSIX: Files Introduction to Operating Systems: Discussion 1 Read Solaris System Interface Guide: Ch. 5.1 Basic File I/O.
University of Washington CSE 351 : The Hardware/Software Interface Section 5 Structs as parameters, buffer overflows, and lab 3.
Copyright 2013 – Noah Mendelsohn Process Memory Noah Mendelsohn Tufts University Web:
Chapter 3.1:Operating Systems Concepts 1. A Computer Model An operating system has to deal with the fact that a computer is made up of a CPU, random access.
Security Exploiting Overflows. Introduction r See the following link for more info: operating-systems-and-applications-in-
Operating Systems ECE344 Ding Yuan Memory Management Lecture 7: Memory Management.
CSC 322 Operating Systems Concepts Lecture - 4: by Ahmed Mumtaz Mustehsan Special Thanks To: Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall,
1 Operating System Overview. 2 Today’s Objectives Explain the main purpose of operating systems and describe milestones of OS evolution Explain fundamental.
8.4 paging Paging is a memory-management scheme that permits the physical address space of a process to be non-contiguous. The basic method for implementation.
Chapter 1 Introduction 1.1 What is an operating system
Processes and Threads CS550 Operating Systems. Processes and Threads These exist only at execution time They have fast state changes -> in memory and.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Chapter 2: Operating-System Structures T.Yang, 2012 Partially based on the.
The Structure of Processes (Chap 6 in the book “The Design of the UNIX Operating System”)
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 7 OS System Structure.
UNIX Files File organization and a few primitives.
Moving Arrays -- 1 Completion of ideas needed for a general and complete program Final concepts needed for Final Review for Final – Loop efficiency.
File I/O, Project 1: List ADT Bryce Boe 2013/07/02 CS24, Summer 2013 C.
Processes CS 6560: Operating Systems Design. 2 Von Neuman Model Both text (program) and data reside in memory Execution cycle Fetch instruction Decode.
Memory Layout, File I/O Bryce Boe 2013/06/27 CS24, Summer 2013 C.
A Tool for Pro-active Defense Against the Buffer Overrun Attack D. Bruschi, E. Rosti, R. Banfi Presented By: Warshavsky Alex.
1 CS503: Operating Systems Spring 2014 Part 0: Program Structure Dongyan Xu Department of Computer Science Purdue University.
Programming Fundamentals. Overview of Previous Lecture Phases of C++ Environment Program statement Vs Preprocessor directive Whitespaces Comments.
Buffer overflow and stack smashing attacks Principles of application software security.
CSE 466 – Fall Introduction - 1 User / Kernel Space Physical Memory mem mapped I/O kernel code user pages user code GPLR virtual kernel C
Chapter 2 Operating System Overview Patricia Roy Manatee Community College, Venice, FL ©2008, Prentice Hall Operating Systems: Internals and Design Principles,
COP 3275 – Character Strings Instructor: Diego Rivera-Gutierrez.
Copyright ©: Nahrstedt, Angrave, Abdelzaher1 Operating System Overview Tarek Abdelzaher Lawrence Angrave Vikram Adve.
Announcements Partial Credit Due Date for Assignment 2 now due on Sat, Feb 27 I always seem to be behind and get tons of daily. If you me and.
Using System Calls (Unix) Have to tell compiler (if C/C++) where to find the headers, etc. – i.e., the “include” files May have to tell compiler where.
“Success consists of going from failure to failure without loss of enthusiasm.” Winston Churchill.
Hank Childs, University of Oregon April 6 th, 2015 CIS 330: _ _ _ _ ______ _ _____ / / / /___ (_) __ ____ _____ ____/ / / ____/ _/_/ ____/__ __ / / / /
Variables Bryce Boe 2012/09/05 CS32, Summer 2012 B.
WORKING OF SCHEDULER IN OS
Virtualization Virtualize hardware resources through abstraction CPU
Process Memory COMP 40: Machine Structure and
Protection of System Resources
Checking Memory Management
Functions Inputs Output
Practice Six Chapter Eight.
Computer Organization & Compilation Process
Memory Allocation CS 217.
Understanding Program Address Space
What does an Operating System Do?
Lecture Topics: 11/1 General Operating System Concepts Processes
Programs – Loading and Running an Executable
CSE 451: Operating Systems Autumn 2003 Lecture 10 Paging & TLBs
Computer Organization & Compilation Process
Presentation transcript:

OS Structure & Processes1 Vivek Pai COS 318 September 19, 2002

OS Structure & Processes2 Foodundgedank You’re the host/hostess of a banquet hall that has accidentally been double-booked. It has three rooms – the large dining room, the cocktail room, and a small buffet line room. You’re the host/hostess of a banquet hall that has accidentally been double-booked. It has three rooms – the large dining room, the cocktail room, and a small buffet line room. If each guest is given a card with the room layout with table numbers, and the guest’s own table number, how can you solve this problem? If each guest is given a card with the room layout with table numbers, and the guest’s own table number, how can you solve this problem? What issues are involved regarding the sizes of the two groups? What issues are involved regarding the sizes of the two groups?

OS Structure & Processes3 Administrative First precept happened, more to come First precept happened, more to come –Friday’s booked – same time, same place Yong is this project’s TA Yong is this project’s TA Project 1 due 11:59pm Oct 1 Project 1 due 11:59pm Oct 1 Almost everyone has given me details Almost everyone has given me details –Get me what remains Next reading assignment: ??? Next reading assignment: ???

OS Structure & Processes4 A Friendly Deception Hiding information Hiding information Giving out different information while appearing to be the same Giving out different information while appearing to be the same Stalling when necessary Stalling when necessary Drawback? Maybe lots of extra work Drawback? Maybe lots of extra work Benefit: makes life easier for user Benefit: makes life easier for user

OS Structure & Processes5 Host/Hostess Problem Each group < 50% Each group < 50% –Have two sets of cards with different numbering schemes Each group slightly above 50% Each group slightly above 50% –Slow down the buffet line & entrance Each group near 100% Each group near 100% –One group in dining room, other in cocktail room

OS Structure & Processes6 Users, Programs, Processes Users have accounts on the system Users have accounts on the system Users launch programs Users launch programs –Many users may launch same program –One user may launch many instances of the same program Processes are instances of a program Processes are instances of a program –The “program” can really be a set of processes

OS Structure & Processes7 Programs As Process Collections Netscape (output of “ps x”) Netscape (output of “ps x”) –7253 p0 S 0:19.26 /usr/local/lib/netscape/communicator-4.75.bin -irix-s –7280 p0 I 0:00.15 (dns helper) (communicator-4.7) gcc (via “gcc –pipe –v”) gcc (via “gcc –pipe –v”) –/usr/libexec/cpp | –/usr/libexec/cc1 | –/usr/libexec/as, followed by –/usr/libexec/elf/ld

OS Structure & Processes8 gcc example You launch gcc You launch gcc It first launches cpp, cc1, as It first launches cpp, cc1, as It then launches ld It then launches ld Each instance is a process, and each program actually exists separately Each instance is a process, and each program actually exists separately –You could launch cc1 manually if you wanted

OS Structure & Processes9 So What Is A Process? It’s one instance of a “program” It’s one instance of a “program” It’s separate from other instances It’s separate from other instances It can start (“launch”) other processes It can start (“launch”) other processes It can be launched by them It can be launched by them

OS Structure & Processes10 What Does This Program Do? int myval; int main(int argc, char *argv[]) { myval = atoi(argv[1]); while (1) printf(“myval is %d, loc 0x%lx\n”, myval, (long) &myval); }

OS Structure & Processes11 Here’s The Output

OS Structure & Processes12 Instances Of Programs The address was always the same The address was always the same The values were different The values were different –Implies that the programs aren’t seeing each other –But they think they’re using the same address Conclusion: addresses are not absolute Conclusion: addresses are not absolute What’s the benefit? What’s the benefit?

OS Structure & Processes13 So What’s In A Process? Information about the hierarchy Information about the hierarchy –What launched it –What it has launched Information about resources Information about resources –Where is it storing data –What other resources it’s using Various kinds of mappings Various kinds of mappings

OS Structure & Processes14 Consider How To Read a File Compare read( ) and fread( ) Compare read( ) and fread( ) read(int d, void *buf, size_t nbytes) read(int d, void *buf, size_t nbytes) read( ) attempts to read nbytes of data from the object referenced by the descriptor d into the buffer pointed to by buf. fread(void *ptr, size_t size, size_t nmemb, FILE *stream) fread(void *ptr, size_t size, size_t nmemb, FILE *stream) The function fread( ) reads nmemb objects, each size bytes long, from the stream pointed to by stream, storing them at the location given by ptr.

OS Structure & Processes15 Which is a System Call and Why read(int d, void *buf, size_t nbytes) read(int d, void *buf, size_t nbytes) fread(void *ptr, size_t size, size_t nmemb, FILE *stream) fread(void *ptr, size_t size, size_t nmemb, FILE *stream) Both do the same thing, right? Both do the same thing, right? What gets “exposed” in each case What gets “exposed” in each case What about a lying programmer What about a lying programmer –How hard is it to tell he/she is lying –What other malicious actions can occur?

OS Structure & Processes16 What State Is Implied? Consider the following sequence: Consider the following sequence: read(int d, void *buf, size_t nbytes) What happens if two programs were doing this?

OS Structure & Processes17 Some Insight Into OS Process Array of File Pointers Actual File Info What do we gain from this?

OS Structure & Processes18 Some Insight Into OS Process Array of File Pointers Actual File Info Process

OS Structure & Processes19 Examining Those Other Parameters read(int d, void *buf, size_t nbytes) read(int d, void *buf, size_t nbytes) fread(void *ptr, size_t size, size_t nmemb, FILE *stream) fread(void *ptr, size_t size, size_t nmemb, FILE *stream) Where is [buf, buf+nbytes)? Where is [ptr, ptr+size*nmemb)?

OS Structure & Processes20 Remember This? Application Portable OS Layer Libraries Machine-dependent layer User space/level Kernel space/level

OS Structure & Processes21 Address Space One (common) approach One (common) approach –Kernel is high memory –User is low memory What restrictions apply? What restrictions apply? read(f, buf, nbytes) read(f, buf, nbytes) 0xffff…. Kernel space User space 0x0000…

OS Structure & Processes22 Some Definitions Kernel – “heart” of the operating system Kernel – “heart” of the operating system –Like the program file generated by compiling all of the operating system files Operating system – usually includes more Operating system – usually includes more –Various libraries –Support programs Hard and fast definitions? Rarely Hard and fast definitions? Rarely

OS Structure & Processes23 More Address Space Program segments Program segments –Text –Data –Stack –Heap Any obvious choices? Any obvious choices? 0xffff…. Kernel space User space 0x0000…

OS Structure & Processes24 One Common Layout Lots of flexibility Lots of flexibility –Allows stack growth –Allows heap growth –No predetermined division So what happens when you So what happens when you make a system call? 0xffff…. Kernel space Stack Heap Code & Data 0x0000…

OS Structure & Processes25 Kernel Stack Kernel contains functions Kernel contains functions –Just like regular functions –Automatic variables, formal parameters, etc –They need a stack Can we use the user’s stack? Can we use the user’s stack? –Is it possible? –Is it desirable?

OS Structure & Processes26 Is The Kernel A Process? Monolithic OS Monolithic OS –Most forms of OS you’ve probably used Layered systems Layered systems –THE system (design) –Multics (design + hardware support) Hypervisors/virtual machines Hypervisors/virtual machines Client/Server (microkernels) Client/Server (microkernels) –Mach

OS Structure & Processes27 What Other Options Possible? Remember the host/hostess scenario? Remember the host/hostess scenario? –What would happen if you had a break between courses –Can you apply this logic to the kernel? –What are the tradeoffs?