DOC PREVIEW
CU-Boulder CSCI 3753 - Processes

This preview shows page 1-2-24-25 out of 25 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 25 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 25 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 25 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 25 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 25 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

AnnouncementsWhat is a Process?Loading and Executing a ProgramWhat is a Process?What is a Process?How is a Process Structured in Memory?How is a Process Structured in Memory?How is a Process Structured in Memory?Why Allocate Local Variables on a Stack?Why Allocate Local Variables on a Stack?Why 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 ProcessesCommunicating Between ProcessesCommunicating Between ProcessesOperating Systems: A Modern Perspective, Chapter 6Slide 6-1Copyright © 2004 Pearson Education, Inc.Processes6Operating 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?Program P1• 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 memoryCodeDataOperating Systems: A Modern Perspective, Chapter 6Slide 6-4Copyright © 2004 Pearson Education, Inc.Loading and Executing a ProgramCodeDataMainMemoryOS LoaderProgramP1binaryCodeDataCodeDataP1binaryP2binaryDiskProcessCPUExecutionProgramCounter (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 spaceassociated 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?CodeDataMainMemoryProgramP1binaryCPUExecutionProgramCounter (PC)RegistersALUFetch Codeand DataWrite DataProcess– 2 processes may execute the same program code, but they are considered separate executionsequencesOperating 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.Implementing the Process AbstractionOS AddressSpaceOS AddressSpaceControlUnitOS interface…Machine Executable MemoryALUCPUPi AddressSpacePi AddressSpacePi CPUPi ExecutableMemoryPi ExecutableMemoryPkAddressSpacePkAddressSpace…PkCPUPkExecutableMemoryPkExecutableMemoryPjAddressSpacePjAddressSpacePjCPUPjExecutableMemoryPjExecutableMemoryOperating Systems: A Modern Perspective, Chapter 6Slide 6-15Copyright © 2004 Pearson Education, Inc.OS Process Management: External ViewApplicationProcessApplicationProcessDevice MgrProcess MgrMemory MgrFile MgrUNIXDevice MgrProcess MgrMemory MgrFile MgrWindowsCreateThread()CreateProcess()CloseHandle()WaitForSingleObject()fork()wait()exec()HardwareOperating Systems: A Modern Perspective, Chapter 6Slide 6-16Copyright © 2004 Pearson Education, Inc.Process


View Full Document

CU-Boulder CSCI 3753 - Processes

Download Processes
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 Processes 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 Processes 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?