来 这个是盘子OK这又剪刀了好 您好早晨好 現在是週二CSE-421 第四季禮拜年這是我們開始的我們開始的我們先說一下今天我會介紹最重要的一個就是這個這幾個月,雖然我不知道,但是在選擇的選擇之間,我們就想決定誰是你最愛的兒子他們都很特別,但我覺得這是一個很好的地方我們會談談過的程序我們會談談如何保護保護的程序在內的程序我們會談談內容保護的程序然後我會用一堆例如,我會展示你如何找出同樣的資訊在自己的機器用一些普通的雲溢修以及一些例如如何處理的程序在其中一個程序裏我們想談談幾個程序首先,我們會談談如果你是不接收電郵在CSE421CSE421的單位把你的手提高我知道,有幾個你應該把你的手提高如果你想接收電郵我們會用這個單位如果你的手提高如果你想把電郵把電郵把你手提高全部的電郵把電郵給你送給自己如果你是不接收電郵我們會用這個單位把電郵把電郵把電郵把電郵把電郵把電郵把電郵把電郵把電郵 New YorkLet me start off with the mayor's call, soLet me see if this is going to work todayIt would be good if I let you inThis is my faultand I appreciate people who came here to takea preterm examI know some of you guys sat around for a whilepulling your jets at 9am or Friday morningwhich is not the kind of thing I like to dobut I really appreciate those who cameI took the exam and feedback is going to be really helpful for us in designing how we do the rest of the class.So thank you and again, my apologies for the mix up.I can promise you that this kind of thing will not happen on the big storm or the final.This is a good chance for me to have some practice and get an exam.All right, so let me do some announcements before I get started.Just make sure these don't fall off the end of Q&A.So we have a mail in this.Like I said, if you're registered for the class, you should be on the mail, right?And we will keep this low traffic.This is just for really course related announcements.It's important for people to have.If you need to contact the course staff, please email staff at mail.cse421.net.That comes to me and the other TAs, and it'll help make sure that you get a fast response.I tend to get, well, I wouldn't say I get a lot of email.I'm just not good with the email I get, so it feels like a lot of email.So if you send email directly to me, it will probably not be answered before.It would have been had you set it to the staff email list.Because there's three, perhaps four of the people that are on that list that will on some level have access to the same state that I want.All right, we have a web server that's up.If you're curious, you can go to the web server page.There's nothing up there yet.We're working on it.Hopefully today we'll have some content, including assignment zero.So we're working really hard to get assignment zero out.The goals have it out by the end of the day today, so you guys can get started half.Probably if it comes out today, we'll be making changes to it and updating you guys as things go along.So download it, take a look at it, set up your virtual machine,but be on the lookout from now so that it's about things that there's bugs.We are going to start the recitations for this class next week.So not this week.This week there will be no recitations.Next week we will start the recitations.Let me do a quick and useful pull about timing for recitations in office hours.So I noticed one of the recitations is scheduled at 8am.Is anybody signed up for that recitation?You guys like to go to a different recitation that is not at 8am?Yeah, but my schedule probably won't allow us.So why don't we do this over the course list?If we can get you guys into another recitation, then we may try to kill off the 8am recitation.That seems pretty brutal.What about the time?What's that?Do you know the other time?Yeah, but I think there's sprinkled throughout the week.So there's one at, I think at 4pm it's another 10am, so we will see.If you can't make it to another one, then we will do one at 8am.And then finally, TA is going to hold office hours for this class.Now, the interesting thing is, this class is at 9am.And since all of you guys have been getting up every morning to come to class,I was wondering if there would be any interest in having office hours after class.I know that that's a time that interferes with other classes you might be taking,but I figure as long as we're dragging you out of bed at 9am,we might as well speak in the pot a little bit about having the TAs aroundmaybe one or two days a week after class to answer questions on the assignment.Is there any interest in this?If you're interested in this razor here,because I think that's a good carrot for people who come to class.Now,however,there's one caveat.If you go to office hours and you did not come to lecture,we will somehow figure out who you are,and we will make sure that you pay.So don't come to 10am office hours if you can't come to a 9am lecture.Right?If you need to sleep in,sleep in,that's fine.I'm not going to take it personally.We'll try to put some videos up on the web.That's why we're taking it today.So,on the other hand,if you come to office hours,and you want to help at 10am,and you weren't able to get up at 9am,then I think the TAs will be less interested in helping.But we will also schedule some PM office hoursin people's office.I know that people have different schedules.Okay.Any additional questions before we get started?All right.So,to start up the day,I want you guys to do something very simple.Everybody stand up.Okay.Turn to somebody here by you that you don't knowand interviews yourself.Good day.Good morning.The other thing is,if you are seated in a seat that has a numberthat is higher than 158,please get up and move into a seatthat has a number that is lower than 158.People from the back or the classroom,please come forward. plenty of room in the front row, guys.This is the room for my committee.I'm sitting here like this.I'll sit there.I'll sit here.I'll sit here.I'll sit like this.I'll sit here.I'll sit here.I'll sit here.I'll sit here.I'll sit here.I'll sit here.This is my high-to-air.We've had some work that we didn't.But I'm in last year.You know the bottom line?I know the bottom line.I'm in last year.You see?You see?我們很想要求以暴力而生而不順利我們很想要求以暴力而生不順利我們不順利不順利不順利不順利不順利所以今天我們要討論運作系統的資訊你們在場我們講了一點點因為它不夠所以它們的主要目標是另外一個在通過的資訊所以今天我們不談運作系統我們會談Processes and processes happen to be the OS abstraction that does not map down to hardware,direct unlike threads, which map down to CPU,virtual address spaces, which map to memory,and files and other file abstractions that map onto disk.So processes are kind of an organizing thing.So we're going to talk about abstractions today,not old-fashioned,and abstractions are designed to do a couple of things.So before when I asked you how many people have usedsome sort of programming or system abstraction,raise your hand again.That's better.Before it was like five of you,and I was thinking,you guys write an assembly code?So if you've programmed in any kind of language,you've used an abstraction,abstractions are designed in the operating systempretty particularly to do a couple of important things.So let's see,what's one important thing that an operating systemabstractions do?So it simplifies the programming style.Right.So it makes,the design makes things easier for the program.It's easier to work with a filethan it is to have to figure outhow to write raw blocks to disk.It's also easier to let theoperated system handle context switching for youthan to figure out how to save your stateand restore it.Now there are libraries that do this.So how many people have useda user space threading library?How many people have used threads on Linux?More than maybe one or two years ago.Then you've used a user space threading library.So this is possible.But in general the idea about abstractionsis to simplify things for the program.Right.What's something else that abstractions do?Right.So abstractions have an interface.Right.That's a property of abstractions.But why do they have an interface?Let me go a little bit.To hide the underlying implementation.Right.So one of the questions on thepreterm that I think that there weresome people that seemed to struggle withwas this question.Maybe it was a trick questionbecause maybe the answer impliedsomething about your fundamental suspicionor feeling of the operating systemsare designed properly.But operating systems are designed toseparate policy and mechanism.Right.Not entangle policy and mechanism.Implementations entangle policy and mechanismare tend to be pretty terrible.Right.We're trying to stay away from those.Right.Operated systems are really designedto do the opposite.We're trying to set the rate of policy.Right.And in some ways,interfaces embody a policy.Right.So an interface creates a contractbetween the caller and the calleethat says this is what the calleewill do for you.And this is what you can expect.But other than that,you can't count on any otherkind of behavior.Right.So when well specified,interfaces allow the callersorry,the callee to do exactlyyou just pointed out.To changethe implementation.So can anybody think of an exampleof this kind of thing.And maybe use an OS abstraction,maybe use a different abstraction.Right.What about files?Is anyone,what's the majorship that's going on infiles storage technologies today?Cloud computing.Cloud computing.Okay.Cloud computing is a good one.I'm thinking of something else though.Flash.Right.We can talk about both.Cloud computing and flash.Right.What is different about flashand spinning disks?There's no moving parts.Right.Flash is solid state.Right.It's kind of like permanent memory.Now when we get to the file systemport of this portion of this course,we're going to studyto some degree,not to a hugedegree because it's kind of startingto be antiquated.A lot of theold tricks that file systems usedwhen disks spun aroundin circles.Right.So what's one property ofdispinning in circles that'ssignificant for file and filesystem design.Okay.That'sfine.If you don't know,justsay that.Let mepeck up something else.Right.Locality matters.Right.There's such a thing asdislocality.So where theheads are,so the disk isthis platter with these littleheads moving around it.And wherethe heads are at a particularmoment in time has an impactit will take to acquirea block of data from anotherpart of the disk.Okay.Is this true on flash?No.Because there's no moving parts.Right.Now,however,just becausethis comes back to anotherpre-turn question,locality isimportant on flash.And that'sbecause flash wears out.Right.We'llcome back to this,but flash.So flash hasdifferent properties thanspinning disks.Right.The nicething is thatdespite the factthatthere has been this big,thereare going on in storagetechnologies,the fileabstraction that operatingsystems have provided to applications has remainedthe same.Right.Theimplementation haschanged,the performancerequirements havechanged and there's a hugeamount of underlyingchange that goes on,butthe fundamentalextraction is still thesame.And at the veryend of today's lecturewe're going to come backto another example wherethe Linux operatingsystem kind of abuses,Ishouldn't say abused,cleverlyreutilizes the file systemabstraction to expose跟不同的資料所以領導分辨 policy for mechanism提供了 an interface提供了 mechanism to changeOK所以在這個項目中我們會討論有幾個因素的領導而我所說的之前很多領導的領導直接往下這些比較漂亮的照片我們會用來提供領導的領導然後希望他們不會改變這項項目是完全可能的可能會發生今天好所以領導的領導是一個領導在領導的領導有幾個領導的領導在領導的領導所以領導的領導是一個領導在我所說的領導的領導領導的領導領導的領導有很多大部分的領導的領導在領導的領導那領導的領導有幾個領導是如何分享領導的領導對好所以你們你們很 familiar with processes對其他 than filesprocesses are probablythe operating system abstractionthe most people the most familiar withSo, what is a process?給我給你一個 example of a processThis is a very easy process對This application is running GIll me an exampleA process that you use recentlyI need a lot of thingsOK, now processesimmediate playimmediate playimmediate fileimmediate playimmediate playimmediate playimmediate playimmediate playimmediate playOK, great, immediate playerapplications, you guys know processes as applicationsI think they've got windows, they've got buttonsthey've got an interfacea lot of processes are user facingyou guys know what these areanother technical problemyou guys over here are talking about processes explorerprocess explorerOK, there we gothe meta processOK, another example of a processchrome, sureyeahso the applications you use on your computerare processesrightand that'sthis is the way to think about themright, so what dowhat processes is integratedso processes havethings that are up on the slideright, so let's go throughOKRoberttell me one of the thingsthat a process containsone or more threadsno stop thereyou can't take two answersgot to get somebody elseone or more threadsright, so what are threadsthreads are represent thingsthat the operating system is doingthreads of executionthings that are halfright, we're going to go throughan example of this in a bitrightsomething else that an operating system containsthis is on the slidethese are easy questionsyou and the buffalo billsanother spaceanother spacealright, I like thatbecause it's kind ofpatriotized almostif I split part of itanother spaceso a process is using memoryit's using memoryfor a variety of differentthingyou could think of memoryas temporary storagetemporary fairly fast storageephemeral storagesomething elsethat processes useit's kind of so far as likereading comprehensionI promise I'm making this hardbut I have some laterlike little reveals on the slideI'm getting better with myright, so operating systemuse filespermanent storagepermanent storage on diskthat tends to survivereboots and processstop and startalright, so processeson an operating systembesides collecting informationorganizing abstractionsthey also provide aprotection boundaryso to some degreean operating systemguaranteesthat multiple processeswill not be able tostop on each otherrightso if I launch a processon my systemit shouldn't be able tokill off other processesmake the system reallyslow and unresponsiveetcnow this is alwaysthe case in practicenohow many people hereare old enough to useto have used likeold versions of windowslike 95, 98so windows took about30 years to discover stuffthat unix had inventedin the 70srightone of those conceptswas protection boundariesbetween processesso old versions of windowshave all sorts of different waysthe processescould stop on each otherand make life miserablefor each othernew versions of windowsten to have fixedthese problemsrightbut to some degreethis is a common themethat all operating systemsshareis that they try to make surethat processescan't stop on each othernow inside of a processthat's your businessrightthat's like your littleprivate domainis the programrightso an operating systemis not going to guaranteethat stuff that you dowith your own resourceswithin the process containerare correctare safeare going to leadto your process behaviorrightbut that's kind ofthe programmersrightso the operating systemis essentiallyguarantineor agreeingto provide these kind ofboundariesbetweendifferent processesand programmersare expectedalrightsoinintroprocess yeahcan you callvirus a processexcuse mecomputer viruswould be called a processbecause it would be runningit crashes the computer as wellso rightokay a computervirus would be a processrightcomputer virusestend to be processesthat exploit bugsin other processesrightso a computerviruswhat is the commonsoat some pointlittle trivia questionfor you guysrightremember which versionwas itvistaMicrosoft Vistacame outsomething liketwo or three yearslaterightand thennobody liked itbutone of the thingsthat slowed downthe watch of Vistadoesn't anybody knowwhat it wasMicrosoft did a hugesecurity auditat their entirecodebasewhere they pulledprogrammers offsecurity reviewsof this hugecodebase that they calledwindowsand othercoursersand the reason for thatwas to try to preventthese sorts of bugsrightso a typicalI'm going to get backto my flow in a minutebut I'm answering a questionbecause I think it's a cool questiona typicalprivilegeescalationrightso as anybodythere are websitesthat record theserightdoes anybody followthis sort of thingfor LinuxI don't reallybut I think it's kind of neatthere are people thatbasicallyhackersfriendly hackerswho go out and tryto break Linuxrightso they try to find waysto escalate their privilegesand what that meansis they try to find waysto execute as the root userrightbecause the root useron the Linux systemhas special privilegesthat can do a lot of nasty thingsto otherto other processesand parts of the systemrightso basicallywhat these people dois they try to find waysof running programsor exploitingholes in thesoftwareso that they can thenget more privilegesthan they're supposed to haverightso typically on most systemswhether it's Windowsor Macor Linuxthere is a special userthat has privilegesthat allow it todo thingsto other processesthat we mightnot normally likerightand that's donefor management purposesif you canmasterate as that personthen you cando a lot of damagerightany other questionsrightso communicationwithin a processis pretty easyrightsomeone can give me an exampleof like a canonicalmulti-threaded applicationanybody have a guessstarting with youron the side of the roomany guessesnothinhow about youcat-progress maybewhat's thatcat-progresslike anything thathas an interfacefrequently will utilizemultiple threadsto do different thingsrightyou have one threadthat's redrawing the screenyou have one threadthat's waiting for user inputyou have another threadthat's doing somethingin the backgroundthat's an exampleof a server applicationto buy itmultiple threadsa web servercanonical examplerightthreads within a processcould communicatewith eachother directlytypically by justusing memoryrightso threadone wants to communicatewith thread3it can just writeinto a shared memoryregionlike keyrightsome of this stuffwe're gonna come backwhen we talk about memorywe're just trying togive you some ideasof where the boundarieslawin terms ofcommunicationthere's a lot of opennesswithin a process itselfrightthis doesn't necessarilymake things easyrightbecause there are a lotof synchronization problemswhen you start to havemultiple threadsand we use somethingthat we will talk aboutin detail next weekcommunication betweenprocessesis harderand more structuredrightwhy is thatwhat's the thingthat the operating systemis trying todo for processesin the backyeahwhat iswhatan operating systemis trying todo what betweenprocessestrying towhy would inter-processcommunicationbe more structuredand more difficultwithin a processthat'sthat's onepossibleit's notwhytrying to get a scheduleand stuffbecause there are a lotof processesoperate andpossibleto watchrightso there could beresearchableproblemsbut I commentedit's somethingmore funaboutthe operating systemis designedtoprocessrightthe OS wants toprotectprocessesfrom eachotherrightand socommunicationbetweenprocessesis onepossible channelwhere myprocessmight do somethingbad to yourprocessrightsofor exampleif I want toshare memorybetween two processesboth processeshave to set upthat share of memoryregion rightso it's an optinsort of thingI can't justdecide to shareyour memoryrightlike you're running alongand I'm likehey I like that pageand I'm going towrite some data into ityou knowthat doesn't happenthat can happen insidea processbetween two threadsbut it willnot happenbetween two processesbecause both processes older versions of windows, this would happen, right, and that was one of the issues, right, because, you know, there could be this kind of sharing that was unintended sharing and where one application was not conducive, right.So here's one way that processes can communicate with each other that maybe illustrates some of these problems. So this is a file that both of these processes had opened down here and process A has written something to the file and process B could read it.What are some of the problems with this? Anybody?Right, so I need to have some semantics for how you and I are going to share this file, right. I don't necessarily know if you're done writing data, I don't know where I can write it, especially, so this is especially critical when two processes are sharing a file and trying to write to the file at the same time, right.Because, you know, if I write data and you write data to the file at the same time, it's essentially a race, right, and whoever writes last, that's the data that's going to appear.How many people have used a file system like NFS? A network-mounted file, right.I am using it.So if you guys have used a shared computing environment, you've probably used something like NFS.So again, we'll come back to this in the file system here, but NFS has very loose requirements for how it opens and locks files.And that can create a lot of problems here because if you're not careful and two, you know, two users that are logged into different machines that are accessing the same shared file can essentially run into this problem.And the real issue on NFS is that NFS doesn't have a notion of a file being opened, which as you imagine is kind of an issue because I can use openness to prohibit other people potentially from modifying the file, right.So if I open the file with certain rights, that means that other processes won't be able to open it, and I know that I can write my data to the file without fear of somebody else stopping it, all right.Questions at this point.I want to go through a couple of other inter-process communication mechanisms because this really kind of helps us get at the process extraction, right.So Exit Codes.When I started writing these slides, this is really interesting, right, so Exit Codes.It's so, I don't know, I'm fascinated by Exit Codes, right.It's just this teeny-weeny little piece of data that processes can pass between each other, right.When a process exits, it returns an int.That's it.Like a number that is, you know, supposed to indicate something about what happened, you know, what did it finish properly, did it crash,etc.That Exit Code is available to the process that created that process.So on Wednesday we're going to talk about process lifespan for exact things like this.But the point is that the return code is one, one very, very limited form of IDC.It can only be sent when the process exits.It is only received most cases by the process parent.So I threw in some examples here that the green's not showing it pretty well,but showing you, you know, how to collect Exit Codes using BASH, right.How many people are familiar with BASH?I know I should know this for the free time.So what I can see here, what does BINTRUE do?Anybody know?BINTRUE.It's kind of a funny program.We'll learn more about this later.It's fine to be open here.BINTRUE returns 0.That's all it does.It's the simplest, maybe the simplest possible unit program, right.And again,0 here is normally indicated, used indicates success, right.Where non-zero indicates failure.And there's a lot of different ways that a process can fail, right.And a lot of time processes will establish fail codes.That means that if a process returns 2, you look that up in some table.And it says, you know, the process ran out of memory or something, right.What about BINFALSE?What do you think BINFALSE does?Should be able to tell.It returns 1, right.Error, right.That's all these things do.So this shows you from the shell how this looks, right.So if I basically run a sleep command, which will wait for 5 seconds,and then run BINTRUE.When it completes, you see that it just says done, right.That's the way of the shell telling you.It just completed, okay, no problem, right.BINFALSE,however you can see that it says exit 1, right.That means that the process BINFALSE exited with exit code.If you've run a command and you don't know what happened,and you'd like to retrieve the exit code after the command finishes,bash has this special variable,which is,I guess,a dollar sign followed by a question mark.It simply says,and that will,if you print that variableor echo that variable to the terminal,that will tell you what the exit code wasthat the process that just ran,it just finished return.And this can be helpful,sometimes you'll run somethingand it won't seem to have done anythingand you'll want to kind of know what happeneddid it work,did it not.pipes,right.Pipes are anotherUNIX IPC mechanism,right.So how many people have run a commandlike the one up therethat used the pipe operator,right.So pipes are a way of transferring databetween processes,right.And again,it's another simplefairly structured form of IPC,right.Linux sets up pipes as essentiallya buffer between two processes.So all the output from my PS commandwill be written into a pipewhere it can be retrieved by the grub command,right.And this is,again,another sort ofstandard way of doing IPCand if it's,UNIX has this design philosophywhere,which maybe distinguishes itfrom some other programming environmentsthat you're familiar withwhereUNIX likes to distributea lot of small utilitiesthat do one thing very well.And then it's your job as a programmerto chain them togetherto achieve something that you want.And I'm sure if you go onlineyou can find examples where peoplehave chained togethersome six different commandsusing pipesto do something,right.So rather than writinga standalone programto do something specializedyou take,special,you knowsingle-purpose programsand kind of chain them togetherin a nice way,right.And this is somethingyou can do from the command line.And this is especially nicewhen you're trying to solvea problem that you thinkyou'll never need to solve again,right.You just need to solvethat one line.Alright,signals.Signals are another formof IPCthat processes can engage it.Signals actually havea lot of overlapwith interruptswhich we're goingto talk about later this week.So processes cansignals are an asynchronousdevice where anotherprocess can senda certain kind of signalto a second process.That process has the optionbefore the signal arrivesof establishing signal handlersto process that signal,right.And a signal handlermeans when that signal arrivesthat process will bewill jump into a signalhandler and executeSo you guys have allI bet anyone who has usedUnix has used signals,right.Arrays your handif you've usedUnix or LinuxHave you used signals?Have you everhave you ever exited a process?How do you do that?I'm just exitinglike a program.No,no,no,but let's sayit's running and you wantto stop it.But how do you do that?Like if you're inthe terminal.PTRL-C,right.PTRL-CPTRL-Cis implemented by sendinga sick-term signalto the process that's running,right.Most processes handlethat signalby shutting down grazing.You can write a processhowever that ignoresPTRL-C.If you write a processby default usingthe standard C librariesPTRL-C will shut down.However,you canwrite your own signal handlerand you can write a processthat if it runsit will sit in a while one loopand if you hitPTRL-C it will not stop,right.I don't know why youwould do something like thatbut it can be done,right.If you look up onlinethere's a whole bunchof different signalsthat you can send,right.So here's an exampleofusing kill,right.Now kill,despiteit's fairly aggressive nameis not just aboutkilling processes.It also sends signalsof anarbitrary number of types,right.So by defaultkill will send sick-termbut you can usekill to send any sick.And some of the signalsdon't kill the process at all.There are signalsthat tell the processre-read your configuration file,right.So if I have a web serverthat's running,for exampleand I've madesome changes to the sitesthat I'm servingand I'll have tostop it and restart itI can send ita certain kind of signalthat saysI've made someconfiguration changescould you re-read it.And if it handles thatprobablyprocesses can alsoignore signalsas I saidsick-kill isone particular exception,right.processes are notallowed to ignoresick-kill,right.Sick-kill willterminate the problem.It's usuallya fairly ugly name.Questions.Ok,so what about signals?I mean is thisa safe mechanism?Can I just senda sick-killto your process?No.Why not?We don't knowwhat does the processthat interact with that.Well it's not just thatit violates theprotection boundariesthat the operating systemis trying to establish.So normally a waysignals work isthat I can only senda signal toone of my ownprocessesthat I've createdthat's associatedwith my user writing.If I try to signalsome other processthe signal justdoesn't get through.Alright,so we'regoing to come backto filesand other things.Alright.I just wantto stop here brieflyand talk a little bitabout terminology.So there can beat times a little bitof confusionbetween processesand threads.And there's alot of terminologyout there.What I'm tryingto do isintroduce you guysto a certain setof conceptsthat basicallymap downto any operatingsystem you use.Windowsis a wholedifferent universe.Linuxsometimes callsthese tasksso anywayyou're going to bea little confusion.So processesand threadspartly the confusionis becauseyou talk about aprocess runningwe'll also talkabout a threadrunning.In this classprocessesare containerabstractionthatand processescan't bescheduledwhich meansthat a threadthat belongsto that processis running.Just seepused.That'show we're goingto find this.All right.So let me go throughan exampleof a processand we'lltalk aboutsome of the partsof the processand what theymight befirefox.Unless you'vebeen livingunder aditch.I guessyou don't liveunder aditch.In aditch.You knowwhat firefox is.What'sthreadsbeendoingWhat'sthreadsbeen doing?Thein theintentional speech.Noin theina.Right,rightright. SoFirefoxwill haveso when Iooked atFirefox onmy laptop我會用火火石頭髮會用火火石頭髮會用電源會用電源我確定火火石頭髮是一個分的髮型至少一個如果你想用火火石頭髮會用80髮這會有很多我會用這個東西會把整個髮型關掉那要用火火石頭髮會用火火石頭髮因為它說每個髮型都會用火火石頭髮我不能說火火石頭髮我用了我用了這類的充滿了火火石頭髮不能動好火火石頭髮會用一整個髮型火火石頭髮會用火火石頭髮會用電源每個髮型都會用火火石頭髮會用火火石頭髮會用火火石頭髮很 created tons of火火石頭髮在我系統上的過程中的過程中對所以在下載時間 loader will mapsome of those shared librarieswhich are filesrightbut they end up being mapped intothe process's address spacebecause they're actually executable codethat the process is actuallyrightand then another examplewould be the heaprightdynamically an allocated memorywhich is probably used for the cacheit's probably used for extension storagerightand then what elsefirefox has threadsthreads have whata stackrightlocal variable storagealrightokthen fileturns out file foxdoesn't actually have that many files overat least when I lookedbut what might it have files over forfilesfilesdid someone say filesoh waitI'm going to pretend you said filesbecause that's a fantastic answerI was surprisedit has file files overI didn't think anyone was going to sayso I'm talking aboutI'm thinking about file fileslike disk filessockets you're rightsockets look like filesbut fontsrightwhat elsefiguration filesso firefox loads somefiguration filesalrightso let me talkwe've got about 10 minutesso let me talk abouthow you find informationabout processeson your own systemrightso how many people have runtopon a system beforerightcoolthis is a pretty useful utilityrightthis shows you a lot of informationabout what's going on in the systemrightI ran thisall thesewere run on our web serverrightjust isn't doing much right nowbut you can seeI mean this gives you a pictureofwhat's using the CPUhow much memory is allocatedhow manyso againlinux has the idea of a taskwhich is essentially somethingthat's runableso a task can beeither a thread with onea process with one threador a thread insidea multi-threaded processrightso this saysthere are 58 tasksright57 of them are sleepingwhat about theseCPU stateswhat do you thinksome of those need0.2% USwhat is thatuserspaceuserspacemount of timethe percentage of timethe system has spentexecuting userspace codeSYjust excuse merightand then IDrightso thismachine's not doinga whole heck of a lotalrightso let's go throughan exampleof a processbashsimple shelland we'll find outsome informationabout howthat you're usingthese utilitiesrightso the first thingI need to dois figure outwhat theprocessed ID isevery processon a systemhas an IDwhich allows the systemto refer to itand allows youto refer to itrightpeople who are too lazyto do the first thingand thenI can alsoif I knowit's money lowrightwhen I log into the machinebash is the only thingso I can just runps and I can seerightso now I've got my process IDrightand that's the beginningof the informationI'm going to applyabout the processand I need thatto collect other piecesalrightso nowI could runps with a little bit moredetailed outputrightnow let's go through thistogetherlet's seeI want to find a roadI'm going to goin this wayUIDyeah there we gonextprocessed IDprocessed IDPKPared Processed IDPared Processed IDgoodlet me go backTRIokput some mobile in over herego PXSCsignsrightso it turns outthat's the amountof memorythat the processcurrently hasactuallyactuallyI don't know what that isit's going to come up nextW Chanso that'skind of a descriptionofif the processis waitinginside the kernelwhich bash iswhat is it doingrightand it turns outthe bash is calledwaitrightwhy did bash callwaitbecause it's waitingfor ps to exitrightit's runninga programwhen I ranrightkeep goingRSSI don't knowmaybe somethingabout sizeso I thinkit has mappedin its outer spacerightand I thinkSZif I remember correctlyis the numberthat are actuallyin memoryrightthis isn't kilobytesso bashis you wouldexpectit's you know3.7 megsof totaland it's onlygot 1.7they'recurrentlyrightkeep goingtimesome measureof how much timethe processhas been runningrightand in this caseactuallyin and bashand bash doesn'tdo much anywayquestionif theprocess crasheswhere is the informationthat itrecovered fromwe'll talkabout thatonce thenis that okayso theexecode is storeduntil theprocess parentreves itif theprocess dumpscorethat's usuallystored in a filein the directoryallright so againhere we goscandalingprioritycore imagesdashdashdashdashdashdashdashdashdashdashdashdashdashdashdashdashdashdashdashdashdashdashdashdashdashdashdashdashdash另一邊,有人說過,這是什麼程序,有幾個程序沒有人說過,這是C.S.421的網絡所以,這裡有,Apache所以,這是Apache,如果我來P.S.,我可以看到,這是我的程序然後,如果我來示範,這其實是17個程序Linux 程序是 known as light processing所以,這是LWP每個程序都有一個I.D.然後,他們都可以預約這些 are all threads that belong to a single processAll right, so let's look at PMAP其實, when I started writing this lecture, I had to use this toolBut it's kind of cool, right?PMAP will show you the memory mapsome description of the memory that's in use by the fileAnd a lot of it isn't very helpful, because for exampleif I allocate heap and then I use it for like firefox configuration filesit's impossible to tap, right?All I can tell is that the process allocates a heapSo again, here's Bache, right?Bache has its code, that's good, right?Now, why do you think there's...So Bache actually has its code mapped three times, right?With different permissions, why is that?So the first segment is marked read and executeWhat do you think that is?What's that?The one you're currently in, the actual terminalSo that's the code, right?That's the immutable code, right?It's executable because I'm executing itAnd it's read only, I can't writeSo there is a history of people that wroteself-modifying programs that would modify their own codeas they ranThat has typically been decided to be a bad ideaSo most, now today, by defaultcode segments get marked as read onlyWhat's the next?It's just readA portion of Bache's code has been marked just readWhat could that be?It's like a critical part of the code that cannot be modifiedSo it can be modified because it's read onlyBut it's also not executableThis is where programs store static variablesA variable that's never going to changeOr some portion of the code that's not executableBut it's never going to changeSo variables that get setThey get set inside their suitable fileAnd then the last part is RWWhat is that?What's that?No, I know it's re-writeRe-write, goodYes, what is it?What's in there?Global variablesExactlyStatic global variables that you allocatein a program go in this areaBecause they're read and written fromBut they're not keepKeep, we dynamically allocate using mailYou can also see that Bache is using some librariesThis is libcImagine it's using libcI'm guessing that 99.99% of the programs are on this machineThis is libcAnd then at the very endI've got one thread and I've got one sendAnd it turns out if you computeThe address thereThat is the very, very, very, very, very, very, very tipity topOf the virtual address space in the processCome back to virtual address settingIn a couple of weeksFinal tool, LSOLF, and this actually can be kind of a helpful tool. I use this a few times. This will show you files that are open by a particular process.And what this shows you is that BASH has file handles that point to the console, standard input, standard output. This is how it reads and writes characters. And that's configuration file.Except for the fact that I made that up. Because when I ran it, LSOLF, there was nothing interesting open.But I just decided, hey, you know, I'm sure when we start BASH, it reads this configuration file. So I just pretended that I caught it right at the right moment.I beg your forgiveness, but it made for a good reason. Alright, so this is it. And this is again, I hope I haven't bored you yet, but I hope I've given you some idea of the components of the process and how they work.So I want to make one quick remark before we leave, because I think that this is kind of cool. So how do these programs that we've just used, PS, TOP, PMAV, LSOLF, where do they get this information from?So it turns out that Linux does this interesting thing, where it exposes this information through a file system interface.So what I've shown here is, I guess I didn't show them out. Okay, if you run MAT on a Linux machine, and you guys will be able to do this later today when you start using our virtual machine that you're going to use for the class, because it's going to run Linux.You see that the PROC file system is mounted on slash PROC. And the PROC file system is not a real file system. It looks like a file system again. I can go in here.So this was my shell 7615. And if I look, if I do have a lesson inside my shell directory under PROC, there's all these files that contain interesting information.And if I had space, I would have showed you kind of what's in it.But this is all fake. The operating system creates this on the fly and as needed in response to things changing.So this is not implemented by writing files onto the file system. This is implemented by intercepting file system calls and doing the right thing.So when LS asks what's in this directory, the operating system intercepts that call and populates it with information appropriate to this particular process.And if I would display these files, it does the same thing.So this is kind of an example of how I can use this hierarchical file system model to organize other pieces of information.So this is something that operating systems do.And actually on operating systems today, there are a lot of what people think of as file-like objects.Sock is network-based files and the PROC files.So it creates its own file system for each process?So under PROC, under slash PROC, if you did an LS under slash PROC, you would see that there was a directory for every process on this system.And they're all across this ID.But again, those calls into the kernel, there's no real file.There's no, like, if you looked, let's put it this way.There are no dislikes that are holding this information.All the information is in memory somewhere.It's probably being challenged so that the operating system doesn't have to rebuild it every time.But these files don't map onto diskbox at all.They're completely constructed to allow processes to retrieve this information in a well-structured way.Otherwise, if so, MAC, for example, doesn't have this.It has a Unix-like operating system, but it does not have PROC.And what that means is that MAC tools that display this information have to make these kind of funky system calls in order to retrieve the information directly from the kernel rather than just navigating PROC.We're done.Do you guys have any questions?So, let me talk quickly about next week.So next week, I wish.So, what available?So I'm going to start putting my slides up onto the website.The slides are all HTML, so putting them on the website is not a hard problem,but the website needs to exist and kind of do something useful first.These slides will find their way up on the web as fast as possible.My first priority today is to get the assignment out,so maybe not for the day or two.But this will be up there.On Wednesday, we're going to talk about the process life cycle.We're going to talk about where processes come fromand the different portion of the operating system interface that we use to manipulate files.No, it's processing.Alright, we'll see you on Wednesday.Thank you.I do turn off this.