DOC PREVIEW
CU-Boulder CSCI 3753 - Implementing Processes, Threads, and Resources

This preview shows page 1-2-3-4-24-25-26-50-51-52-53 out of 53 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 53 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 53 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 53 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 53 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 53 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 53 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 53 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 53 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 53 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 53 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 53 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 53 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Slide 1AnnouncementsWhat is a Process?Loading and Executing a ProgramSlide 5Slide 6How is a Process Structured in Memory?Slide 8Slide 9Why Allocate Local Variables on a Stack?Slide 11Why Allocate Dynamic Variables on a Heap in the Process’s Address Space?A Process Executes in its Own Address SpaceImplementing the Process AbstractionOS Process Management: External ViewProcess Manager ResponsibilitiesProcess Manager OverviewOS Process ManagementMultiple ProcessesContext SwitchingContext SwitchesMultiple Processes: State DiagramCommunicating Between ProcessesSlide 24Slide 25Slide 26External View of the Process ManagerSlide 28Modern Processes and ThreadsProcesses &ThreadsThe Address SpaceBuilding the Address SpaceTracing the Hardware ProcessThe Abstract Machine InterfaceSlide 35Process DescriptorsWindows NT Process DescriptorWindows NT Process Descriptor (2)Windows NT Process Descriptor (3)Windows NT Thread DescriptorCreating a Process in UNIXCreating a Process in NTWindows NT HandlesSimple State DiagramUNIX State Transition DiagramWindows NT Thread StatesResourcesUsing the ModelA Generic Resource ManagerProcess HierarchiesSlide 51UNIX OrganizationWindows NT OrganizationOperating Systems: A Modern Perspective, Chapter 6Slide 6-1Copyright © 2004 Pearson Education, Inc.ImplementingProcesses, Threads,and Resources6Operating Systems: A Modern Perspective, Chapter 6Slide 6-2Copyright © 2004 Pearson Education, Inc.Announcements•Extension til Friday 11 am for HW #1•Previous lectures online•Program Assignment #1 online later today, due 2 weeks from today•Homework Set #2 online later today, due a week from today•Read chapter 6Operating Systems: A Modern Perspective, Chapter 6Slide 6-3Copyright © 2004 Pearson Education, Inc.What is a Process?•A software program consist of a sequence of code instructions and data–for now, let a simple app = a program–CPU executes the instructions line by line in fetch-execute cycle from RAM–code instructions operate on data–A program is a passive entity•A process is a program actively executing from main memoryCodeDataProgram P1Operating Systems: A Modern Perspective, Chapter 6Slide 6-4Copyright © 2004 Pearson Education, Inc.CodeDataMainMemoryOS LoaderProgramP1binaryLoading and Executing a ProgramCodeDataCodeDataP1binaryP2binaryDiskProcessCPUExecutionProgramCounter (PC)RegistersALUFetch Codeand DataWrite DataOperating Systems: A Modern Perspective, Chapter 6Slide 6-5Copyright © 2004 Pearson Education, Inc.What is a Process?•A process is a program actively executing from main memory–has a Program Counter (PC) and execution state associated with it•CPU registers keep state•OS keeps process state in memory•it’s alive!–has an address space associated with it•a limited set of (virtual) addresses that can be accessed by the executing codeCodeDataMainMemoryProgramP1binaryCPUExecutionProgramCounter (PC)RegistersALUFetch Codeand DataWrite DataProcessOperating Systems: A Modern Perspective, Chapter 6Slide 6-6Copyright © 2004 Pearson Education, Inc.What is a Process?–2 processes may execute the same program code, but they are considered separate execution sequencesCodeDataMainMemoryProgramP1binaryCPUExecutionProgramCounter (PC)RegistersALUFetch Codeand DataWrite DataProcessOperating Systems: A Modern Perspective, Chapter 6Slide 6-7Copyright © 2004 Pearson Education, Inc.How is a Process Structured in Memory?float f4=3.0;main() { char* ptr; ptr = malloc(); foo1();}foo1() { int a1; ....}CodeDataMainMemoryProcessP1global variablesfunctionslocal variablesdynamicallyallocatedvariablesOperating Systems: A Modern Perspective, Chapter 6Slide 6-8Copyright © 2004 Pearson Education, Inc.How is a Process Structured in Memory?float f4=3.0;main() { char* ptr; ptr = malloc(); foo1();}foo1() { int a1; ....}CodeDataMain MemoryProcessP1global variablesfunctionslocal variablesdynamicallyallocatedvariablesHeapStackOperating Systems: A Modern Perspective, Chapter 6Slide 6-9Copyright © 2004 Pearson Education, Inc.How is a Process Structured in Memory?•Run-time memory image•Essentially code, data, stack, and heap•Code and data loaded from executable file•Stack grows downward, heap grows upwardUser stackHeapRead/write .data, .bssRead-only .init, .text, .rodataUnallocatedRun-time memoryaddress 0max addressOperating Systems: A Modern Perspective, Chapter 6Slide 6-10Copyright © 2004 Pearson Education, Inc.Why Allocate Local Variables on a Stack?•Strawman approach: pre-allocate all local variables a priori before a process starts executing, just like global variables•What’s wrong with this strawman?–if a function is never called, then you’ve wasted space allocating its local variables–don’t know a priori how many instances of a local variable to allocate if a function calls itself, i.e. recursionOperating Systems: A Modern Perspective, Chapter 6Slide 6-11Copyright © 2004 Pearson Education, Inc.Why Allocate Local Variables on a Stack?•So allocate local variables only on an as-needed basis•A stack provides a simple way to allocate local variables as needed–When a function is called, allocate its local variables on top of the stack - push them on the stack–when a function completes, deallocate these local variables - pop them off the stackOperating Systems: A Modern Perspective, Chapter 6Slide 6-12Copyright © 2004 Pearson Education, Inc.Why Allocate Dynamic Variables on a Heap in the Process’s Address Space?•Strawman II: could ask the OS to allocate dynamic variables anywhere in memory–very complex keeping tracking of all the different locations in memory•Keeping the dynamic variables in one area (the process’s heap) associated with the process’s address space simplifies memory managementOperating Systems: A Modern Perspective, Chapter 6Slide 6-13Copyright © 2004 Pearson Education, Inc.A Process Executes in its Own Address Space•OS tries to provide the illusion or abstraction that the process executes in its own address space, on its own CPUCodeDataMain MemoryProcessP1HeapStackOperating Systems: A Modern Perspective, Chapter 6Slide 6-14Copyright © 2004 Pearson Education, Inc.OS AddressSpaceOS AddressSpaceImplementing the Process AbstractionControlUnitOS interface…Machine Executable MemoryALUCPUPi AddressSpacePi AddressSpacePi CPUPi ExecutableMemoryPi ExecutableMemoryPk AddressSpacePk AddressSpace…Pk CPUPk ExecutableMemoryPk ExecutableMemoryPj AddressSpacePj


View Full Document

CU-Boulder CSCI 3753 - Implementing Processes, Threads, and Resources

Download Implementing Processes, Threads, and Resources
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Implementing Processes, Threads, and Resources and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Implementing Processes, Threads, and Resources 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?