Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "OS Structure & Processes1 Vivek Pai COS 318 September 19, 2002."— Presentation transcript:

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

2 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?

3 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: ???

4 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

5 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

6 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

7 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

8 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

9 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

10 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); }

11 OS Structure & Processes11 Here’s The Output

12 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?

13 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

14 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.

15 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?

16 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?

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

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

19 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)?

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

21 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…

22 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

23 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…

24 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…

25 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?

26 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

27 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?


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

Similar presentations


Ads by Google