 So let's get started, so how are you guys doing? Ready for the midterms? Good. So today I don't really have much to offer, but this is what we do anyway. So I will give you a quick review of the materials covered in the midterm. This is not meant to be comprehensive, just to give you some pointers to where you should look at in the slides. And I'll give you some midterm teams, especially from the graders' points of view because I and other TS will be writing the exam and I want to explain what do we expect in those midterm questions. So at first, at the beginning of this semester, Jeff talked about the abstraction of the process, especially what's inside a process. We have thread as the abstraction of the CPU, and we have address spaces which is represented in the memory, and finally we have files. The entire semester is all about the various abstractions inside the process, for example for threads. Because we have multiple threads running at the same time, so we have concurrency, we have synchronization, and we have rest conditions, and we have all kinds of synchronization problems. And for address space, we have the virtual versus physical memory and how to translate between them, what destructor we use to help us do the translation, and what's the hardware facilities are there available to help us do the address space management. And for the file, I believe you haven't talked about the file system in the lectures, but before that we already look at how we provide file abstractions in the system. In particular, we have three layers of abstraction of file systems, which is the file descriptor in the user space, the file handle per process private, and the file object, which is system-wide. And also, I want to go over the system costs, especially the file-related system costs, to get familiar with these kind of abstraction, and how do we actually implement them in the real system, which is OS161 of course. So this process abstraction basically defines the whole theme of this semester. The latter contents are mostly about this. So for example, for synchronization, we talk about critic section, both in the lectures and in the recitations. So what is the critic section? And what kind of synchronization primitives we have to help us coordinate the access to the critic section? And for primitives, we have lock, we have semaphore, we have CV and reader-write locks. So we want to quickly go over the code in the assignment one to get familiar with these concepts. And also, we talk about synchronization problems in assignment one, which is the coordination of the well-metting problem, which is nothing particular, but here the dialogue is really an important concept. You need to understand why dialogue happens. We have four conditions to cause a dialogue, which is basically, each process needs exclusive access to the critic section. We have the dependence of weighting. What other two conditions to produce a dialogue? So there are four conditions to cause a dialogue. I mentioned two, which is the mutual access to the critic section and circular weighting. No preemption. And there's the final one, which is... I can't remember actually, but therefore. So you want to be very familiar and be very clear with these concepts. And also, given these four conditions, how to avoid dialogues. So basically, by avoiding that, we mean if you break one or just one of the four conditions, you avoid dialogue. For example, in the intersection problem in assignment one, how do you avoid dialogues? So we have four quadrants as four shared resources. And so how do you guys solve the problem? Which conditions you break? Circular dependency. So the way to break it is every car just grab the lock in a certain order. So there won't be two cars who grab a lock and want to grab another car's lock. That's one way to break the dialogue. There are other ways of doing it. And so you may encounter such problems in the exams. So this is for synchronization. And we have interruption handling. This is also related to the stress abstraction of the process. Because we have more stress than the CPUs, so we need to do context switch. We need to do scheduling. To do that, we need to have some hardware interruptions happen in a periodic way so that the kernel can take control and decide which process or which thread to run next. So you need to be familiar with the process of the interruption handling. What happened when there was an interruption? And we also explained this a lot when I was in the resuscitation at 7.2. So for example, there I talked about the software interruption or software exception where the user program used the Cisco instruction to get kernel's attention. When user used an instruction called Cisco, there is a software exception happens. So then what happened? So can you still remember what's the first thing the hardware would do? Go into a privileged mode. Then what? What's that? Save the state. But before that, to do that, so the way to do it is kernel stores the interruption handler in a specific place, which is OX Alamedia in the BIPS hardware. So whenever there is an interruption, the hardware first go into a privileged mode and then jump to that location. That location is agreed by the hardware and the kernel. Then in that small piece of code where there's all kinds of assembly code going on and saving all the context, then finally trapping to kernel's interruption handler. And kernel first figure out what happened by looking at some registers containing the exception course, why the exception happens, and then handle the exception. And then finally, when kernel handle the exception, the kernel returns to user mode but gives some information back to the user and to return the values. That's the Cisco case. And you need to link this to all other interruption cases. For example, another special case is where when there is an address exception, basically the user access a virtual address that doesn't have a translation in the TRB. That's another kind of exception you will see a lot in Summary 3, basically. So what happened there? The process is similar but the exception course is different. And also because the user program uses the address all the time, so you would expect far more address exceptions than the Cisco's and others. Because we have far more exceptions like that, the hardware may have some specific mechanism to deal with that interruption, to try to optimize the performance. So the hardware may have deal with the TRB fault in a different way than normal exception. And you need to have some idea of what's the difference there, how the hardware will accelerate the interruption handling process for TRB exceptions. And then we have context switch. Basically every now and then the hardware has an interruption where the kernel takes over and decides which process to run next. And because of this, we have scheduling problems. Basically the which process to run as the next active process. You have all kinds of scheduling algorithms and you need to know them and what's their advantages and what's the disadvantage of each scheduling algorithm. So next we have the memory management. So here the most important concept is the virtual address. Why do we need a virtual address? What do we mean by address is virtual instead of physical? What's the difference between that? And given a virtual address, for example, user access virtual address 0x400. What does that mean? How does the kernel find the actual physical address that associated with that virtual address? To do that we both need hardware support, which is the TRB, also software support, which is the kernel data structures that maintain the mapping between the virtual and physical addresses. So we have patch table and we may have different translation data structures. Patch table is one if you use paging. By paging we mean that we always use a fixed size allocation chunk for k bytes. Again there are advantages and disadvantages of this mechanism. If you use the fixed size patch there will be no external fragmentation, but you may have internal fragmentation. Another way of doing this transaction is instead of using a patch table you use a segment table where each segment can have a variable size. Again that approach has its own advantages and disadvantages. So you need to get familiar with what's in there in the address space. We have code segment, which is the user program code, of course. And we have data segment, which is the static data that's declared in the user space. And we also have two dynamic regions, which is the stack and heap. So you need to know what the stack looks like. I'm pretty sure you know what it looks like if you do exact v. There you manipulate the user stack quite heavily. So the user stack always starts from the fixed top and grows downwards. Instead users heap always starts from other fixed locations after the user's other segment and grows upwards. So you need to kind of have a picture of where those segments are and how they are changing. And finally we have TLB. Again you need to understand why do we have a TLB. So how does a TLB help the address translation process? So this is all the concepts you need to kind of be comfortable with when you prepare for the midterms. If you don't get confused of any topics or any sentence I say here you better go back and dig through the slides and figure out and study the concepts. So next this is the format of the exam. It should be exam, not example. I assume you already know it because you see all previous year's exam papers. So we have basically ten multiple choices and we have in total six short answer questions and you need to choose four out of the six. And we have two long answer questions and you're supposed to choose one of them. So the exam is 50 minutes and we have 50 points so you kind of know how many time to allocate for each type of the questions. If you find yourself spending far more time in the short answers like you have only 10 or 15 minutes left for the long answers that's a better sign of time management. So if you have 10 minutes for the 10 multiple choices then you should spend at most 10 minutes. Similarly for the short answers you should spend no more than 10 minutes or 25 minutes tops on the short answers. So here are some tips for the exams. So first of all the most important tip is that you need to figure out what we expect to use for you to answer. So for each question, most of the questions state very clearly what do you need to answer. For example here this is a short answer question I take from the last year's midterm exam. So you need to identify those sentences that tell you what to do. So here you need to name one of the abstractions, that's one point and you need to describe why it's useful, that's two points and you need to explain how it's provided, that's another two points. So when you do the exams you need to kind of know what to expect, what we expect, then you go ahead and try to answer those questions. So that's a very important step to read the questions. I mean really read the questions and parse it. And another tip is that don't try to overflow the pages by putting everything you know in the answers. For short questions we expect no more than five sentences tops. So before you write anything you want to be kind of organize your source and figure out what to answer and put the answer very consciously. If you force us to dig the answers by ourselves within paragraphs of text then we'll probably not find the point and you will probably lose the point. And also try, it's not required but recommended that you organize the answers in the bonus point to help us get what you are saying more quicker. So this is the final slide. For the answer questions like I said you need to reserve at least 15 or 20 minutes for it. And most of the answer questions as you may have already noticed is not something you will hear from the lectures. It's kind of some new concept that recently come up from last year's conference or even this year's conference. But at the end of the day if you look at what the question asks you will find is something related to what we covered in the lectures. So for the long answer questions don't get panicked if you see a lot of new concepts and very funny stuff. So try to link what the question asks to what we have learned in the class. Try to approach the questions that way. And also the long answer questions usually have some pointers to you or some hints to you to help you answer the question. Just like the example we see in previous slides we also have some sentences like first do this then do that and finally do this. These are the points we expect you to explain in your answers. And that's pretty much what I got from the review and we still have time so I'll be very happy to if you have any questions on the last year's exam questions or any other questions in general I'll be very happy to answer them. Yes that's the recommended way of doing it just split the questions into sub-questions and try to answer them separately. Concurrency is speaking about the processes where multiple processes have the illusion of executing at the same time while in practice or in reality they are executing sequentially because of the context switch and because of the multiplexing stuff happening you get the illusion of that multiple things happening at the same time. And atomicity is the property of some resources where even though multiple processes accessing the same resource there has to be an order that cannot happen at the same time. That's the atomicity. For example there are some instructions that cannot be interrupted. That's atomic instruction where either it gets executed through or it doesn't get executed at all. Are there any exam questions you want me to explain from last year's or the previous year's? Several instructions? A set of instructions. A set of instructions. That's one way of saying it. Yeah I think that's an acceptable way of saying it. So we have last year's or previous year's exam and if you look at the solutions you will also find the rubrics that we used when we graded. For example... Not necessarily I think. Oh yeah I look at the final. But the final also covers the materials before midterm. I can't remember exactly. I think last year the final only covers materials after the midterm. So you're right we shouldn't see the final. We should see the midterms. Yeah again be prepared for the first question. So if you look at the rubrics you will find that you'll get a sense of what we expect the answers to be. Short and split. No any particular questions you want me to explain? Practical ones are pretty old. I think that's the first year's. Yeah again this question is about scheduling and what's the advantages and disadvantages of... So you will find a lot in that in system not in OS system but in system in general you have a lot of trade-offs. For some threshold or for some system parameters you always have pros and cons of choosing the parameters. For example here if the... can you actually see it? So for example in run-robin scheduling if you choose the time scheduling quantum too long what will happen? Your system will be less responsive. Some background job may take too long to finish and some foreground job may have opportunity to run. But if it's too short for example you schedule every 1 millisecond it's quite... it's quite frequent. What's the disadvantage of that? Contact switch overhead. What's the advantage of that? You get a turn around time each process gets a little bit of more chances to run and be able to adapt to the workload changes more agilely. And there will be such questions this every year so address... virtual address translation. So I would recommend you to go over the questions from last year and then the year before last year and really get comfortable of doing such translations. Are you guys allowed to take the calculators? Oh, yeah. You need to do the calculation by hand. So anyway each year there will be such questions and this year there's no exception so be prepared for such questions and page tables. I want to see the long answer questions. This is not typical long answer questions. The second is a typical long answer question. You will see a block of text which you need to interpret and digest in a very short timeframe and try to link the questions to what you have learned. Basically first you need to figure out what this question is about. For example here, priority inversion this is about scheduling. Then you need to digest the materials and then figure out what's expected. First do this, then do that and organize your answers in such a way for us to see what you are trying to get at. I guess this is pretty much it. So good luck with the midterm. Thanks.