Real-Time Systems and Scheduling
Transcript
So I have I guess 2. two announcements to make First A. uiz will be. released sometime. after the class. And the deadline will be 11:00 AM. on Friday. and then the second announcement is about. your. Project so lab 3. the deadline is next Monday, so. please don't forget the deadline there. won't be any extensions, so try your best to. make it come to the deadline. OK, so I guess that's. pretty much what I have for announcements. Let me get started so. today we're going to talk about real time systems. So we'll start with some definitions. and then we describe.
What are the desirable properties that are real? time operating system has to have and then we compare? what we have in general purpose operating. systems and what we want in a real. time operating systems and that comparison. actually is very informative. So once that is done we. get to the Main. topic of this lecture which is. Real time scheduling. So we will start with a. uni processor. Real time scheduling and then we talk about. multiprocessor scheduling in a real time system. OK so.
Let me get my video out in. That you just see the slides. OK. So. A real time system is defined by its temporal. aspect as well as. it's functional aspect. So what? we want from a real time system is a real. times.
Sorry, real time operating system is its timeliness. It's its ability to. To deal with the temporal aspect. of the system. So usually when we talk about. temporal aspect, what we really mean is that we. have tasks in the system that have deadlines. and strict time constraints. So in those systems, when you. talk about performance, you no longer. talk about average performance. You don't talk about average. response time.
All you care about is have you or. haven't you met the deadlines so? each individual response time becomes. important, not the average. And a key property of. A real time system is its predictability. so everything in a real time system has. to be predictable. Please note the difference. between predictability and being fast. or having high performance 'cause you still can have. high performance and not be predictable so. what we really care about in real time system. this comes up again and again and again. So what we really care about is predictability. We predict can we estimate how long each? task each job takes in? our system?
So there are different types of real time systems. We have soft real time systems, so in these systems. you have a deadline, but you might. fail to meet that deadline. And if you do so then nothing dramatic. happens, so it's. best depicted by this picture. So in this picture. what I have is on the X axis I have the deadline so. basically the time this point. Is basically the deadline of my task, let's. say and on the Y axis I had the value and usefulness. of this task. So if I finish my.
task anytime before its deadline. I get full value out of this task. If I missed the deadline. By the value I get out of this task starts. diminishing linearly. Until he gets to zero and after that if I finish. this task, there is no value. In finishing it then. you have firm real time systems so. in this case you have a firm deadline. which if you miss then. you won't get any value out of finishing the task. So same as before, you have a deadline if you finish. your job anytime before the deadline, then. you get the full value out of it. If you. miss the deadline, then you get 0.
And finally we have hard real. time systems, so these systems. The like the previous ones, have deadlines. but if you missed the deadline, something really. bad happens and you start getting negative. utility afterwards. So if you missed the deadline. now there is there is a penalty associated. with it. So if you look at a spectrum of. systems you. could potentially put them somewhere between. not a real time system to a hard. real time system, and usually systems are somewhere. in between. So in the middle I have the soft real time system here hard. and then no. Basically, if you're doing computer. simulation. those who work with Microbiology. with chemistry, they want to do simulations. Maybe like you want to do.
Simulations of structures in. physics. Whatever that be you. really don't have really hard deadline. so these computer simulations are. usually not real time. Then you have user. interfaces. Here you get to see. some notion of deadline some notion. of responsiveness is important, but it's still. not a big deal if. one time you click on. On that link and it takes a little bit more time, nothing. really bad happens, so here. in the middle I have cruise control, for instance is.
a soft real time deadline real time system you. want to be responsive? You want to have a deadline, but even if. you don't, you don't hit your. deadline. Not nothing really bad happens. You start missing some value. and then at the. end of this spectrum you have. Something like electronic engines an flight. control. So in those cases, if you really. miss the deadline, bad things could. happen. Their lives on the line. in these systems, so this. should give you a good perspective.
on what we really mean by soft, hard and. firm real time systems. Now. In a series of slides will. talk about different aspects of operating. systems that we've seen, and one particular aspect. that we haven't yet seen about. memory management, and we will compare how general. purpose operating systems deal with those aspects. and how that way of. dealing with those aspects is inadequate. Inadequate for real time systems.
Generally speaking. multitasking and scheduling is. 1 area that you see if you see. the huge difference. So usually when. you talk about multitasking and scheduling in a general purpose. systems, you're basically talking. about throughput. And you want. the high the highest. performance you can get out of Multitasking and scheduling so. The way that we so far talked about it was. we provide system calls to. the user so that user can use those system calls to. create tasks and threads to achieve what it wants.
But as we will see. a system calls. Are detrimental and harmful for? real time systems and they really don't fit well. with the mission of real time. operating system now. The same goes with interrupt management. the same that the way that we deal with interrupt. management in an in a general purpose operating. system is through interrupt handling, which. is basically what you're doing for a lab. Treat an. what real time. Sorry, what interrupt.
handling does is that it's kind of like the highest. ity thing in the system. When an interrupt happens, you. Hold on to whatever you were doing and you. start dealing with that interrupt. Now you could imagine. what would happen if what you were doing was. something related to the electronic engine. or the flight control, and then the interrupt handler. takes some time and that could potentially. lead to missing the deadline. for that hard real time task so. that's another aspect that. will see differences between general purpose operating systems. and real time operating systems.
The other area that. is also important and we will see in this in. these slides going forward is how we. basically deal with interprocess communication and. synchronization between tasks. Seen a general purpose operating systems. You have a critical section. Somebody locks the. mutex and everybody else has to wait for that somebody. Now in the context of real time operating. systems, you will have to deal with some. priorities. So some tasks have. hired. The sooner deadlines and.
than others. Some tasks have higher priority than others. And you really don't want these high priority tasks. to be waiting for low priority tasks. or tasks with deadlines that are far, far from far, far in the. uture. So you want to deal with priority. inversion, something that you really don't deal with. in a general purpose operating system will. talk about all of these, and some actually some more. Now, what are the desirable? properties of other real time operating system?
We start with predictability so. we want to make sure that we can meet. all the deadlines. We want proofs and guarantees. that all the deadlines as long as they. meet some. criteria then we can definitely meet them. So we. want to say if they, for instance, if the utilization of the. system is less than one. If your system is not over utilized. Then every task will meet its deadline that. that's basically predictability with that, what that means.
We want a real time operating system. to have timeliness meaning. that it has to be able to deal with. time constraints that tasks could have. hard, firm or soft deadlines. We want also to fault tolerance. as you could imagine. in for instance in a in. an engine in an Electra Lektronic engine. you don't want a fault of. why are there 2 crash the whole? engine? You want to isolate the. fault and then deal with it in isolation. without crashing the entire system and. you also want to design. Or peak load and you want to maintainability. things that actually matter a lot in real time. systems. So let's start with. microarchitecture. Will start with hardware and then.
we make our way up to software things. that are a little bit different from general purpose. systems and real time systems now. One aspect of processors. is IO Devices, Your. input output devices so. we talked about DMA at the beginning. of the course.
I think it was the 2nd lecture where. we talked about four main concepts. of operating system where we talked about DMA's. So usually IO. devices share a same bus. with the CPU when it. comes to communicating with memory. So if you remember. I'm just. Reminding everyone what DMA was so DMA was. when the CPU would let. a device to take care of. data transfer without CPU being involved. So that was good in a general purpose. system. It would give a really good performance. But what is negative about it? in real time system is that. With DMA. IO devices could slow down the. CPU and the reason for that is the. fact that both of them share the same bus. So if I. devices are using that bus a lot then there operate the.
CPU, which potentially could be running high. priority tasks will be backlogged. So one way to deal with this with this is. to time slice. The boss. so basically what we did. with. Something like round robin where we had time. quantum time quanta and then each task. would get it's time quanta. You could do the same thing. with the bus that connects both. CPU and IO devices to memory so. you can have time slices. If you do so. then CPU knows how many times slices it has. on that bus. And it could predict how long. it takes to do its tasks so. there is no on deterministic aspect. to it, no stochastic aspect to it, because previously.
if they share then we don't really know what's going to happen. with IO devices. Maybe you get a lot of packets through. your network card at that. particular moment of time the bus becomes. really overloaded on CPU gets backlogged, but if you have time sharing you have. Time slice the bus, then you have guarantees. of how much at least you get to use the. memory bus. The other aspect when. it comes to microarchitectures caches so will have. e a cold lecture on caches, but. Hopefully by this time you all know what is. main purpose of caches so we have caches to. speed up memory operations. We want to cache. the already seen data. Very close to the processor so that. the next time that I need to. access that data I have it very close to the processor. and I can access the access. the data very fast. Now the problem with cash.
This is perfect for general purpose operating. systems because it speeds up everything but. the bad thing about it for real time systems is. that it introduces some nondeterminism and. The reason for that is that you really don't know which data. is cashed and which data is not cached. so something very similar to a non. uniform memory access is that we talked about previously happens. here. So when you access a memory block. it could be cached. In that case the.
execution time of that load is really really fast. Or it could be not cashed. In that case you. have to go all the way to the memory to bring it, or in some cases you. have to go to the disk and that takes a lot of time so. there is non determinism and that is detrimental. and harmful for a real time system 1. ne solution for this is to just get rid. of all the caches. Don't use caches. It's pretty dramatic, but if you really. are dealing with real time. systems, this is this is the way that many. people go so. You could design your own processor or there. are actually microprocessors that you could you. could use without caches. So that you don't need to deal with that non determinism.
OK, so now let's move on to. some interface between software. and hardware. In particular, let's talk about system. calls and interrupts. So as I eluded. in the beginning, the system calls are the. way general purpose operating systems. provide services right to the software now usually. As you have seen it in your lab. System call handlers are non preemptive. so you Disable interrupts at the beginning of them and. you enable interrupts when you return from them and.
while you're doing it, you're basically disabling all. the interrupts. So I got a question. What if you always assume a cache miss ann if? you happen to get a hit, you just. complete the task early. OK, so this is a good question, this is. true, so you could potentially. have worst case guarantees. for your tasks and that is fine. The problem though is that is the nondeterminism that. it introduces, so. Although you might have be. able to prove that in worst case I can deal.
with the deadline, but it actually introduces non. determinism and that could be harmful. if you have a chain of tasks, for instance that. are related to each other. So you have to 1st do this. task and then next task and then next task maybe. they share a lock or. mutex. So and then if you allow each. one of them. To have worst case and best case or something in between. then analyzing the workload as a whole. becomes almost impossible. so maybe for that one task you could.
guarantee stuff. But if you have a. L workload with so many tasks. And each one of them you allow it to have a. range of execution time then. it's almost impossible to guarantee anything. for that workload as a whole. That was a good question, OK? So now. Yeah, this way of dealing with system calls going. back to the system calls, but what we were discussing is. fine with general purpose operating. systems where we don't have any deadlines. but if you actually have a real time system with. deadlines then that could potentially. cause problems. Let's say your task calls. on to a system call. And let's say, for whatever reason, the system. call take some time. Now.
While the system called is running, let's say another. task comes in with really high priority. With a very a close deadline. that you have to meet. Now at this point, since the interrupts. are disabled, there is not much you can do in. reclaiming the processor and giving. And that could cause a missed deadline. And unpredictability. Really, in your system. So one solution, a possible solution. is to, well, let. interrupt handlers to be preemptive as well.
In a sense that doesn't. That doesn't introduce a lot. of problems, so. It's doable an. it's the way to go if you're designing an. a real time operating system now. things are a little bit more complicated when you. talk about interrupts. System calls are synchronous. More transfers they are initiated. by the processor. by the process that is running by the task that is. running, but interrupts come. asynchronously from external. events that happen in the system. Now, with interrupts, you really cannot. make them non preemptive we talked. about all the all sorts of issues that could happen. if you let the interrupts. to happen inside each other. You might end up not dealing with the first interrupt. the happen because further further interrupts.
come and then they all preempt each other so. To make them preemptive. we can't do that, so. what can we do then in this case? So the. same problems. I'm not going to explain the problems again, I mean. you could imagine why having. nonpreemptive interrupt handlers would cause. some unpredictability in your system. Let's. say you are running your task and then an external event happens. So based off of how many events happened during. your execution. Your execution time basically changes, and because you cannot.
control external events, then your execution. time of your task is basically not preact predictable. Now one solution is to just. disable all the interrupts altogether. Don't let them. even happen. Only keep the. timer interrupt so that you get. to as scheduled tasks. as usual and. You still need to deal with IO devices, right so? what you can do to just move? all the responsibilities of dealing with? IO devices to each individual task? so any task that needs to deal with.
IO they deal with IO individually. So just as an example to. make this connection with the project that you're doing. right now. So in our project. we have two. 2 units, two tasks that deal with interrupts. Sort of so it's. kind of isolated between those two tasks. Anybody else? all the other tasks, although they can? indirectly use the terminal? But they don't need to know how to so. the entire logic of. dealing with devices goes to. particular tasks. In this method that I have here solution one. you have to enable every task. to individually be able to deal with IO. devices as they wish. So if you have a task. that deals with network this task.
has to have all the drivers logic. in it to talk to the network or. talk to the display or the keyboard. or mouse. And as you can see this is. good because it. It basically makes now my tasks to. be predictable. Now they're not interrupted, but. or two more benefit of this. You can actually estimate precisely. how long it takes for you to do data transfers. because you're pulling basically right every time. a task needs to do, I owe it. pulls because you cannot do interrupts without.
interrupts. Your only way of dealing with IO is pulling. So you can definitely pull for as much as you want. and then start pulling so there is. a precise timing for you can estimate. exactly how long it each data transfer takes. And the other good thing about it is. that you don't need to change anything in your inside your kernel, right? Because now tasks are dealing with their iOS kernel. is not doing anything Colonel's side by side.
At the tasks deal with IO and such, so there is no change. If you want to add a new device, the kernel doesn't need to. do anything, well, that. The bad thing about it, though, is that now. You're degrading the performance of your CPU because of. polling, because polling is. Wasting time, right? You're just if you have. infrequent events in your. IO. You're basically wasting CPU time the 2nd. ond problem with this approach is that. now you have to have very very. rich device logic. in all your tasks. And let's say you change the device. or you add a device to your system. Now all the. programmers have to go back and reprogram their tasks. and the other applications.
So what are the other options the 2nd? ond option is the second option is as before. Disable interrupts again, don't let interrupts. happen, only keep the timer interrupt. but instead of. Putting the IO device logic. in all tasks. Put them in a specific. A kernel routines so. right function calls. Inside kernel that would deal with IO. And then a periodically like say. y, set a timer. Let's say every one second. every one millisecond, everyone microsecond. whatever wake up wake this kernel.
And what do these routines do? They basically pull again. on the device on IO devices to see if there is any. data and if there is then they will deal. with it. Now what are the good things about it? Again, because we have. disabled interrupts we have. We don't have to. deal with unbounded delayes. The execution time of these periodic. routines can be estimated as before. so before it was inside the tasks, now it's in the kernel. But again, I can basically estimate how. long it takes. And the benefit over the previous one is that now? I have a I have a modular design. where the hardware details details don't.
need to be leaked into the tasks, they are just all. isolated inside kernel. Now the bad things about it is that I haven't dealt with the performance. degradation of the performance because I'm still pulling. and that still wastes CPU time, I'm busy. aiting for the CPU. The other bad thing about it is that now I have to. modify the kernel every time I add or. remove a device or upgraded device. or whatever. So now the kernel has to change. Which sometimes is that big deal you have. to recompile the entire kernel, react you have. to change and in some cases you can't change. nge the kernel on fly you have to basically shut down the entire system. bring the system up again. In some cases some. extreme cases and the third one. is now the communication is a task.
wants to do, IO has to go through. multiple hops and you would. definitely need some. More Inter task communication. compared to the first one, the first one, each task. does its own IO, but now you have to go to the. kernel and then come back to the to your devices. and that actually adds some Inter task communication. and Deley. What is the third option? So the third option is.
We really cannot keep. the interrupts disable and. do anything about the performance degradation if. you really don't want to deal with the performance degradation, you. have to let interrupts happen, so you'd you. enable interrupts this time, but. In order to write it, sorry instead. of writing interrupt handlers that are. rich and do a lot of things and could. take a lot of time, you could reduce your. device drivers and interrupt handlers to. the least possible size.
So they are as they do as little. as possible. What they usually do. which is very similar to what we had with the bottom half. on top half, is that these. Device drivers and interrupt handlers. In real time systems they activate. Other tasks so. They. I'll create a new task or wake up. a new task. That is already running in the system and give it and you. knew instruction to do based. on the interrupt that happened, so all they're doing. is basically sort of message passing of. some sort that will. This thing happened. Now it has. e dealt with and that's it. That's all it does. And then the operating system treats these device. driver tasks that are now either created. or woken up like. the other tasks in the system they.
also have their own deadlines, and they all dealt with. how other tasks are dealt with they. don't have higher priority and then others that they. could actually, but not generally speaking so. you can actually predict and have some guarantees for your system. because now. All you're dealing with is bunch of tasks and very. lightweight interrupts. So compared to the previous ones. We have eliminated busy waiting so no performance. degradation anymore because we have enabled interrupts. The other thing about it is that we don't really. need to do any changes inside our kernel where. the delegating the. task of dealing with interrupts to the device drivers and.
But the cost we're paying is. that. First of all, there is some communication. again compared to the 1st first one. between the tasks and. the device drivers to transfer data. This is sort of minimized now, right? It's not as high as it was with the. second option, but it's not as. low as it was with this first option and. the second costs that we're paying is we're. still dealing with unbounded. delayes, so we still have. might have unbounded delayes.
Because we're still dealing with unexpected. device driver handling, but. The cost and. the probability of that happening has been reduced. dramatically because now we don't have really. long interrupt handlers, we. have made them as light as possible. and that's the advantage of this model and. by the way, this is basically I think, as far as I. know, this is what. Many operating real time operating systems. do so this the it's the third solution. that is used usually.
OK so. The next stop for us isn't is to talk about memory. management. This is slide is. kind of like futuristic in. the context of our lectures will have. series of slides and lectures on memory management. coming after actually right after this. The lecture on real time system. So I'm going to deep. dive into this but just to give. you a give you all. the things that you need to know about. A real time system. I have put it here so just.
Listen to these even if you don't. get everything here, you can come back to it after we finish. memory management and virtual. virtual to physical address translation. later on in the cores. Then you can come back to this slide. and probably get a lot more out. of it than what you could at this point that. being said. This is like basically summarizes the. next four or five 5 lectures that. are coming. So in one slide I'm just summarizing all. of it, so in general purpose operating systems.
what usually happens is that you want protection for your processes. and as you could remember, we used memory mapping. or address mapping and address translation. For this we give each process as. separate virtual address space. And then we translate those virtual addresses which. virtual addresses to physical addresses. Now, in order for us to do this efficiently. what usually general purpose operating systems do? is that they divide the memory into pages. both the virtual memory.
and physical memory is divided into pages. fixed size pages. I got a question so. what would be the difference? Between the solution 3. And using top bottom driver. halves in general purpose operating systems. it's a good question so then. The general. the general idea is the same. It's kind of like how you implement them. because we top and bottom halves you still. could do a lot in both of them, so your. bottom half or your top half. could still be doing. a lot. They don't really create knew tasks.
They manage everything inside themselves, what? we're suggesting here with this methodology. is in solution 3. Is that instead. of doing any sort of logic or algorithm? there, instead of implementing anything specific. Just create a new task. So that knew task can go and deal with it. even if that knew task is to, let's say, initiate the. DMA. Don't do it yourself. Create a new task to. do the DMA stuff or create a new task. that copies data between the memory an.
buffers inside devices. So just do the. minimal amount of work. To wake up and you task or to create a new. task to deal with the issue. you have. So that's the main difference. Hopefully that. Answered the question. OK, so we're talking about memory. management now with the. With these pages, what address? translation becomes is basically. translating these virtual pages to physical pages. We want a mapping to tell us where. to find each one of these virtual pages inside our. physical memory. Both of them are paged, so we just. want a mapping between virtual pages and an physical pages. where this is a stored, it is usually. called page table. So we have page table. inside our memory system. We'll talk about it in details where we store these mappings now.
Going to these mappings and finding. this translations usually takes a lot of time. and introduces a lot of overhead. so as a result, many. odern hardware. processors. They have cash. close to the processor to. cash these address translations, so if. I have already translated. Virtual page 2 two physical. page 5. I can cash this translation so that. if in the future I see this address again. I know the translation. I don't need to go. back to the memory again. So this cache is very small.
as you could imagine and it's called. Translation Lookaside buffer TLB. In short, so many operating system. modern so many modern architectures have this. right now. What is the problem with this? The problem with TLB is the problem we had with caches. Like before, when I started talking bout Marco Architecture caching is. introduced nondeterminism if you. hit in the cache, if you can find the translation. in TLB, then your address translation is very. fast. But if you can't, then you have. to go to the memory to get that address translation. Now this is fine in a general purpose system. but in the real time operating system and real time system. this is. This basically costs you.
Predictability now one possible solution. that actually many many many. real time operating systems and real time systems. do is to just avoid. ing virtual memory. So just deal with physical. memory as we will talk later this. introduces a huge inflexibility in the system. and could cause a lot of security. risks, but this is sort of fine. With most of real time systems and partially. with I mean generally speaking with embedded systems. because usually real time systems.
Are owned by a single user an. are written for a single task. Let's say that. the electronic engine so. you really don't mind the security. risk because you're the only user in the system you're. writing all the tasks everything belongs to you so. you're fine with it. You don't really need that isolation. sort of. I mean, it would depend, right? But? in many cases that is something that people. are willing to pay.
Now the other problem with everything. that I said above is something. that will also talk about which is called paging. What usually happens in Indiana? Our systems is that. Our processes think that they have. a lot of memory. The virtual memory space is. big, but usually the physical memory. is a small depending on. how much ram, how much dram you have in your system. As a result, operating systems do something. that is called paging or dim and paging. and basically what that is.
We use the memory. As a cache for disk. Right, so basically all the pages. all the visual pages for each process can. be kept inside the disk. In the hard disk, in the permanent storage. and every page that the process actually. needs and uses, we bring them to memory. Once the memory is full and we don't have a space. anymore and some process wants to. Access it's pages that are not in the memory we. have to evict a page that is already in physical. memory. Write it back to the disk and. bring the page that we need. And as you can imagine, this process is absolutely. time consuming. Writing entire page back.
to the disk and bringing a new page back. And this is actually the same way now if memory. y is acting like a cache for disk cache is. always provide nondeterminism. So one way to deal with this whole thing. is to just pin your pages, tell the operating. system that you cannot evict this page, so. if you have a real time task with. Deadlines. You can basically pin all the pages for this. task to the memory until operating system. you're not allowed to touch. These are not electable.
and that way you sort of sure. that you're not doing paging on. the memory of this task and that. kind of like. Mitigates the problem you have with paging. OK, the other problem, the other aspect. to consider is programming language is one of the. aspects of programming languages is dynamic memory. operations, which is basically what you did with lab. one allocating the heap.
One of the big tasks of any. language and any library to. manage a program is to allocate. memory as needed dynamically. Now, if you. have looked into the lectures. that were shared with you for lab one, you probably. have seen these terms about fragmentation. And the reason? that dynamic memory is not. something that we want to have in a real time. system is because it's usually. unpredictable. As you saw, hopefully and implemented.
To allocate memory, we usually implement some heuristic. best fit first fit. Or worse, fit. So there are heuristics to use now. The execution time of that algorithm to find. a memory for the requested. let's say Malik. Is non deterministic so it could. You could find the space right. where your free list starts. or you might have to go through the entire list. to find the place that you need. right? And that is non deterministic. How much? it takes for you to find that memory location. And since most of these are heuristics. they usually cause or lead to. suboptimal allocations and. what that causes is basically fragmentation. Here is an. example. So let's say you Malik 3. three cache, sorry memory.
blocks, and you basically look at your. free memory here. I think I have 10 you. allocate the 1st three to this pointer. P1 becomes the pointer to the beginning. of these three. Then let's say you do another. malloc in your application and you. request for four extra. Blocks And again, we're lucky we can. just get it right away after that three allocated. ones. Then, let's say you free P. So now P1 is freed that. memory is now available. Now you. initiate and you Malik for four and.
as you can see in this case you have enough. space to allocate. But they're not contiguous, and as a result. you cannot. Basically. Answer this. This request and it would fail so. even though you have free memory. You cannot serve this request. and if you think I can defragment. I can move those four. allocated ones to some other place and. make a space for the new request. That is really not possible because. P2 could have been copied. right? You might have different copies of. P2, all of them pointing to that 4th. A block and the library has. no means to track how many copies. of P2 have been created. So if now I move that. memory, all the previous copies would.
be pointing to something that is not valid anymore, so. So it's not an option to defragment. at this point. So all of this basically is nondeterminism. Unpredictability as a result. of fragmentation and running optimization. algorithms. So one possible solution to deal. with this whole thing is to instead. of allowing. Allocation of different sizes you. could make a fixed size memory blocks. and allocate those. So let's say you. could divide your memory to whatever you want an at each time.
Everybody can just request one of those blocks. This causes more fragmentation. in usually internal fragmentation, which. we will talk about a lot in more details in. the memory section of this course, but that. probably you could imagine if, let's say I have. this 10 units, I can say OK. Divided into 2.
Units of size 5 so. Even if this guy needs three, I'm gonna give it a. 5 unit. And. That basically means that 2 units are going are not going to be. used to bytes or whatever that unit is. but which is internal fragmentation. But that's sort of fine as long as I can prevent. external fragmentation another. solution which is widely used in. real time systems is to just prevent dynamic. data structures so many real. time systems do not allow. dynamic memory allocation, so whatever memory. you need, it has to be a statically allocated.
It gets the gets flexibility away from your system. but it at least it gives you predictability. The other aspect when you're talking about programming. languages is recursion. This is. also something that is highly unwanted. in real time, operating system and real time systems. because you could get infinite loops. It's really hard to guarantee anything. if you have if you have. Recursion and you don't know. and the number of recursions depend on an input. or data. So if the number of. recursions is determined dynamically. then there is no way for you to.
guarantee anything about execution time and it. becomes unbounded. And there are examples of real time programming languages. with some or all of these features. You have real time Java. and some other. Real time operating programming languages that you can potentially. look into. OK, So what time is it? I'm going to give you 2 minutes and. then we'll start talking about scheduling.
OK, we're back. Let's go ahead with scheduling so. Are they included at the beginning for general purpose? schedulers? The goal is to minimize. some sort of average system throughput, but for. real time systems were more interested in. tasks an each individual task. So we're talking about now minimizing of worst case. response time for each task and as. I mentioned.
Predictability? Is not equal to fast computing. When we're talking about real time tasks. There are different types of real time tasks. The one that we most. Mostly focus on is periodic. tasks, so periodic tasks. Each periodic task is a set. of jobs. That arrive at fixed period, let's say P.
An each job has a worst. case execution execution time. We call it and it. has a hard relative deadline that. is usually less than. I mean, it has to be less than P. And if it's not mentioned if. we don't say anything about a deadline for a periodic. task, you should assume that the deadline the relative. deadline is basically P. It's the period.
And then we define utilization for each task so. utilization of a task is. The execution time, the worst case execution time of its. jobs divided by its period. So the jobs inside. a periodic tasks are. basically identical. Identical jobs coming periodically. And each one of them will take some worst case execution. time if you wish, so. This is how we show. T7 Four the 1st. st one is the period, so every seven. time units. It dropped comes. And each job will take for A. its worse case.
And then the relative deadline when you don't mention it. here is basically 7, so you have. to finish your task by the time that. the next one. Sorry you have to finish this job. So the relative deadlines becomes the period now. there are other types of real time task you could have. a period periodic. tasks. That basically come. Randomly and they don't have hard. deadlines. You can have a sporadic tasks. that come randomly bought have. hard deadlines you when and then when you. when you talk about set of tasks then. your tasks could be independent. Or they could be dependent.
Your tasks, your tasks. could be preemptible or non preemptible. OK so. Now that we know about tasks, let's. talk about scheduling and terminology for scheduling. the first class of the schedulers is are. basically a static schedulers. So static is schedulers. they assign a priority to each task. And the priority of the task never changes overtime. So.
One example is written, not monotonic scheduling. which we will see. Then you have dynamic schedulers. So dynamic is schedulers instead of putting. giving priority to each task, they give priority. to each job. And the priority of a job never changes, but. as you can see, because tasks have. Jobs that are arriving overtime. so as single task could get different. priorities because it's jobs are. getting different priorities but each individual. job whenever it's assigned a priority.
that priority never changes. And an example of this is earliest deadline first, which. will talk about. Then you have fully dynamic scheduling so. these ones you're assigning priorities. to jobs. But that priority could actually change overtime. So it's the most flexible one. and an example of it, which is latest. axity first, sorry, least. laxity first scheduling LF.
So we say a scheduler as is feasible. If it all, if it so. if we're talking about sorry schedule. If I give you a schedule. Of tasks Then you can say it's feasible if all tasks. meet their deadlines. Now. It task is a schedulable. Under is scheduling Class C.
If there exist as scheduling algorithm a. in C that produces feasible. schedule 40. And finally, as scheduling. algorithm a is optimal. with respect to a particular class. of a schedulers. If it, if it produces feasible schedule. For any schedulable task set. T undersea.

Ask anything
We've read this whole study set, so questions about it get the best answers.