DOC PREVIEW
CMU CS 15410 - The Process

This preview shows page 1-2-16-17-18-34-35 out of 35 pages.

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

Unformatted text preview:

Slide 1Slide 2Slide 3Slide 4Slide 5Slide 6Slide 7Slide 8Slide 9Slide 10Slide 11Slide 12Slide 13Slide 14Slide 15Slide 16Slide 17Slide 18Slide 19Slide 20Slide 21Slide 22Slide 23Slide 24Slide 25Slide 26Slide 27Slide 28Slide 29Slide 30Slide 31Slide 32Slide 33Slide 34Slide 3515-410, F’04- 1 -The ProcessSep. 13, 2004Dave EckhardtDave EckhardtBruce MaggsBruce MaggsL06a_Process15-410“Now I know why they call it a 'cursor'”15-410, F’04- 1 -SynchronizationProject 1Project 1Hope you've run simics by now!“End of today”paint character on screenposition cursorAnybody reading comp.risks?Anybody reading comp.risks?This lectureThis lectureChapter 4, but not exactly!15-410, F’04- 1 -OutlineProcess as pseudo-machineProcess as pseudo-machine(that's all there is)Process life cycleProcess life cycleProcess kernel statesProcess kernel statesProcess kernel stateProcess kernel state15-410, F’04- 1 -The ComputerStackProgramRegistersKeyboardScreenTimer15-410, F’04- 1 -The ProcessStackCodeDataHeapRegistersstdinstdouttimer15-410, F’04- 1 -Process life cycleBirthBirth(or, well, fission)SchoolSchoolWorkWorkDeathDeath(Nomenclature courtesy of The Godfathers)(Nomenclature courtesy of The Godfathers)15-410, F’04- 1 -BirthWhere do new processes come from?Where do new processes come from?(Not: under a cabbage leaf, by stork, ...)What do we need?What do we need?Memory contents●Text, data, stackCPU register contents (N of them)"I/O ports"●File descriptors, e.g., stdin/stdout/stderrHidden “stuff”●timer state, current directory, umask15-410, F’04- 1 -BirthIntimidating?Intimidating?How to specify all of that stuff?How to specify all of that stuff?What is your {name,quest,favorite_color}?Gee, we already have Gee, we already have oneone process we like... process we like...Maybe we could use its settings to make a new one...Birth via “cloning”15-410, F’04- 1 -Birth – fork() - 1““fork” - Original Unix process creation system callfork” - Original Unix process creation system callMemoryMemoryCopy all of itMaybe using VM tricks so it' s cheaperRegistersRegistersCopy all of them●All but one: parent learns child's process ID, child gets 015-410, F’04- 1 -Birth – fork() - 2File descriptorsFile descriptorsCopy all of themCan't copy the files!Copy references to open-file stateHidden stuffHidden stuffDo whatever is "obvious"ResultResultOriginal, “parent”, processFully-specified “child” process, with 0 fork() parameters15-410, F’04- 1 -Now what?Two copies of the same process is Two copies of the same process is boringboringTransplant surgery!Transplant surgery!Implant new memory!●New program textImplant new registers!●Old ones don't point well into the new memoryKeep (most) file descriptors●Good for cooperation/delegationHidden state?●Do what's “obvious”15-410, F’04- 1 -Original ProcessStack/bin/shDataHeapRegistersstdinstdouttimer t=415-410, F’04- 1 -Toss Heap, DataStack/bin/shRegistersstdinstdouttimer t=415-410, F’04- 1 -Load New Code, Data From FileStack/u/b/gccDataRegistersstdinstdouttimer t=415-410, F’04- 1 -Reset Stack, HeapStack/u/b/gccDataRegistersstdinstdouttimer t=4[Heap]15-410, F’04- 1 -Fix “Stuff”Stack/u/b/gccDataRegistersstdinstdouttimer off[Heap]15-410, F’04- 1 -Initialize RegistersStack/u/b/gccDataRegistersstdinstdouttimer off[Heap]15-410, F’04- 1 -Begin ExecutionStack/u/b/gccDataRegistersstdinstdouttimer offHeap15-410, F’04- 1 -What's The Implant Procedure Called?int execve( char *path, char *argv[ ], char *envp[ ])15-410, F’04- 1 -Birth - other waysThere is another wayThere is another wayWell, twospawn()spawn()Carefully specify all features of new processComplicatedWin: don't need to copy stuff you will immediately tossPlan 9 rfork() / Linux clone()Plan 9 rfork() / Linux clone()Build new process from old oneSpecify which things get shared vs. copied“Copy memory, share files, copy environment, share ...”15-410, F’04- 1 -SchoolOld process calledOld process calledexecve(char *path,char *argv[ ],char *envp[ ]);Result isResult ischar **environ;main(int argc, char *argv[ ]){ ...}15-410, F’04- 1 -SchoolHow does the magic work?How does the magic work?15-410 motto: No magicKernel process setup: we saw...Kernel process setup: we saw...Toss old data memoryToss old stack memoryLoad executable fileAlso...Also...15-410, F’04- 1 -The Stack!Kernel builds stack for new processKernel builds stack for new processTransfers argv[] and envp[] to top of new process stackHand-crafts stack frame for __main()Sets registers●Stack pointer (to top frame)●Program counter (to start of __main())15-410, F’04- 1 -WorkProcess statesProcess statesRunning●User mode●Kernel modeRunnable●User mode●Kernel modeSleeping●“Blocked” awaiting some event●Not run by scheduler●Q: Is this user mode or kernel mode?15-410, F’04- 1 -WorkOther process statesOther process statesForkingProbably obsolete, once used for special treatmentZombieProcess has called exit(), parent hasn't noticed yet““Exercise for the reader”Exercise for the reader”Draw the state transition diagram15-410, F’04- 1 -DeathVoluntaryVoluntary void exit(int reason);Hardware exceptionHardware exceptionSIGSEGV - no memory there for you!Software exceptionSoftware exceptionSIGXCPU – used "too much" CPU time15-410, F’04- 1 -Deathkill(pid, sig);kill(pid, sig);keyboard ^C  kill(getpid(), SIGINT);Start loggingkill(daemon_pid, SIGUSR1);% kill -USR1 33Lost in Spacekill(Will_Robinson, SIGDANGER);I apologize to IBM for lampooning their serious signal»No, I apologize for that apology...15-410, F’04- 1 -Process cleanupResource releaseResource releaseOpen files: close()●TCP: 2 minutes (or more)●Solaris disk offline - forever (“None shall pass!”)Memory: releaseAccountingAccountingRecord resource usage in a magic fileGone?Gone?15-410, F’04- 1 -“All You Zombies...”Zombie processZombie processProcess state reduced to exit codeWaits around until parent calls wait()●Copies exit code to parent memory●Deletes PCB15-410, F’04- 1 -Kernel process stateThe dreaded "PCB"The dreaded "PCB"(polychlorinated biphenol?)Process Control BlockProcess Control Block“Everything without a user-visible memory address”●Kernel management information●Scheduler


View Full Document

CMU CS 15410 - The Process

Download The Process
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 The Process 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 The Process 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?