Vivek Pai - PowerPoint PPT Presentation

About This Presentation
Title:

Vivek Pai

Description:

You're the host/hostess of a banquet hall that has accidentally been double-booked. ... If each guest is given a card with the room layout with table numbers, and the ... – PowerPoint PPT presentation

Number of Views:81
Avg rating:3.0/5.0
Slides: 28
Provided by: valued85
Category:

less

Transcript and Presenter's Notes

Title: Vivek Pai


1
OS Structure Processes
  • Vivek Pai
  • COS 318
  • September 19, 2002

2
Foodundgedank
  • Youre 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 guests own
    table number, how can you solve this problem?
  • What issues are involved regarding the sizes of
    the two groups?

3
Administrative
  • First precept happened, more to come
  • Fridays booked same time, same place
  • Yong is this projects TA
  • Project 1 due 1159pm Oct 1
  • Almost everyone has given me details
  • Get me what remains
  • Next reading assignment ???

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

5
Host/Hostess Problem
  • Each group lt 50
  • Have two sets of cards with different numbering
    schemes
  • Each group slightly above 50
  • Slow down the buffet line entrance
  • Each group near 100
  • One group in dining room, other in cocktail room

6
Users, Programs, Processes
  • Users have accounts on the system
  • 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
  • The program can really be a set of processes

7
Programs As Process Collections
  • Netscape (output of ps x)
  • 7253 p0 S 019.26 /usr/local/lib/netscape/c
    ommunicator-4.75.bin -irix-s
  • 7280 p0 I 000.15 (dns helper)
    (communicator-4.7)
  • gcc (via gcc pipe v)
  • /usr/libexec/cpp
  • /usr/libexec/cc1
  • /usr/libexec/as, followed by
  • /usr/libexec/elf/ld

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

9
So What Is A Process?
  • Its one instance of a program
  • Its separate from other instances
  • It can start (launch) other processes
  • It can be launched by them

10
What Does This Program Do?
  • int myval
  • int main(int argc, char argv)
  • myval atoi(argv1)
  • while (1)
  • printf(myval is d, loc 0xlx\n,
  • myval, (long) myval)

11
Heres The Output
12
Instances Of Programs
  • The address was always the same
  • The values were different
  • Implies that the programs arent seeing each
    other
  • But they think theyre using the same address
  • Conclusion addresses are not absolute
  • Whats the benefit?

13
So Whats In A Process?
  • Information about the hierarchy
  • What launched it
  • What it has launched
  • Information about resources
  • Where is it storing data
  • What other resources its using
  • Various kinds of mappings

14
Consider How To Read a File
  • Compare read( ) and fread( )
  • 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)
  • 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.

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

16
What State Is Implied?
  • Consider the following sequence
  • read(int d, void buf, size_t nbytes)
  • read(int d, void buf, size_t nbytes)
  • read(int d, void buf, size_t nbytes)
  • What happens if two programs were doing this?

17
Some Insight Into OS
Array of File Pointers
Process
Actual File Info
What do we gain from this?
18
Some Insight Into OS
Array of File Pointers
Process
Actual File Info
Process
19
Examining Those Other Parameters
  • read(int d, void buf, size_t nbytes)
  • fread(void ptr, size_t size, size_t nmemb, FILE
    stream)
  • Where is buf, bufnbytes)?
  • Where is ptr, ptrsizenmemb)?

20
Remember This?
Application
Libraries
User space/level
Kernel space/level
Portable OS Layer
Machine-dependent layer
21
Address Space
  • One (common) approach
  • Kernel is high memory
  • User is low memory
  • What restrictions apply?
  • read(f, buf, nbytes)

0xffff. Kernel space User space 0x0000
22
Some Definitions
  • Kernel heart of the operating system
  • Like the program file generated by compiling all
    of the operating system files
  • Operating system usually includes more
  • Various libraries
  • Support programs
  • Hard and fast definitions? Rarely

23
More Address Space
  • Program segments
  • Text
  • Data
  • Stack
  • Heap
  • Any obvious choices?

0xffff. Kernel space User space 0x0000
24
One Common Layout
  • Lots of flexibility
  • Allows stack growth
  • Allows heap growth
  • No predetermined division
  • So what happens when you
  • make a system call?

0xffff. Kernel space Stack Heap Code
Data 0x0000
25
Kernel Stack
  • Kernel contains functions
  • Just like regular functions
  • Automatic variables, formal parameters, etc
  • They need a stack
  • Can we use the users stack?
  • Is it possible?
  • Is it desirable?

26
Is The Kernel A Process?
  • Monolithic OS
  • Most forms of OS youve probably used
  • Layered systems
  • THE system (design)
  • Multics (design hardware support)
  • Hypervisors/virtual machines
  • Client/Server (microkernels)
  • Mach

27
What Other Options Possible?
  • 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?
Write a Comment
User Comments (0)
About PowerShow.com