Transcription and Subtitles
Transcript
No, not two separate things I know. Now it's going back to. Transcription and recording 'cause the last one recording didn't have the transcription, so there's no subtitles. Have no idea of what teams is doing. Far too confusing. OK, they seem to have both are recording and transcription so. With subtitles for the recording if you need them. Don't forget you can turn on subtitles anytime it does a simultaneous transcription and you can have him come up in the screen if that's the sort of thing like.
'cause I noticed there was a Begg. Uhm? News story this week that you guys all watch everything with subtitles on anyway, which I don't understand, but OK. Right, so this is the last topic that's going to come up in the test. So it's the second block of these five topics, and it's. A boat and put output.
That's funny coming in office. Get default. Sorry. Away. Move. Well, I wonder how I take that out of my recording. OK Jordan, I'm gonna mute you just now. Because, you know, we don't need to yell at whatever it was. You know we're not postings and youtubes or town is kid friendly and we don't have to change that now.
OK, so we want to talk about Biosystems today, UM? And this clearly follows on from this stuff. That would be doing for the last couple of weeks because. We were talking about how we sell fail systems, how we set up my storage systems and of course these types of systems are connected via input output systems. Uhm?
But there are different types of IO system. They work in different ways and they have to connect in different ways, both for the operating system. But also for the user and for any applications that you create. So fair warning that some of this stuff. In this lecture. Is aimed towards people who will be programming IO. For the operating system. I'll try and point out is we come along. If you're not a programmer. If you don't think you'll ever be.
Programming any IO devices, that's fine, just let it wash over you. And. You won't be disadvantaged in terms of the assessment of left. Some of the stuff in there because. It is pertinent as interesting, but perhaps not to you if you're. If that's not your thing. OK, so we'll go through this and we'll talk about how we connect to it and different types of ways to try and understand how that's gonna work. Uhm?
So, as you probably already know. Uh. There are many different types of input output system. Just look at your device that you're using just now if you've got. Uh, a PC in front over here for example. I'm just looking at my setup here and I have a USB device connected to my keyboard. I've got one monitor connected via HDMI. I've got one monitor connected via an. Oh gosh, what's it called mini DV?
Ah, I also have a VGA connector, but don't have monitor connected to that. Not just the ones I can see internally, there's a whole bunch of other IO connections. Things like Saturday bases for hard disks. And if you've got an older machine, that might be yeah. Uh, yeah I see or something like that. So the whole bunch of devices all working.
To get data in and out of your system. And they're all very different. Some of them are fast. Like an SSD. Some of them are painfully slow, like a tape or a printer. However, we set up our operating system, it has to cope with all these different types of device. All these different ways that they're connected all these different speeds and all these different ways that we need to interact with them because some are two way. We send and receive data somehow. One way we only send data to this monitor, for example.
We only. You might only get input from some other device, so we need to make sure that the cope with all of that stuff. So we're going to need hardware to cope with that. We're going to need ways to connect. We're going to need ways to transfer the data. And we're going to need to control all these different types of devices, so could have ports were kind of buses were going to have device controls all working together harmoniously with the operating system. Just saw. Like you can type on your keyboard.
Because we have all these different devices, you remember way back we spoke about our lowering the operating system to connect to new devices and we talked about having device drivers. Specific software that spoke to specific devices, taking into account via particular. Set up their particular functions and how they need to be. I am connected to.
Image spoke about that you know two months ago. Something like that, uh, and most of you identified that you had. Install the device driver at some point or other. You probably have to install a device driver. If you get a new mouse these days. So we get new modes and your printer and your keyboard and you monitor. You probably have to install a new device driver, and the same happens with your internal devices, graphics cards, desks, all that kinda stuff.
That's because we have all sorts of hardware identified, some types of connector earlier, but of course even with the different types of connector on your machine, they might connect two very different types of devices. I spoke about my keyboard connected to USB, that'll get a mouse connected to it. I've caught a USB thumb drive. I've got a USB. Hot desk would be portable hard disks. I've got my phone connected via USB.
I have also a great yeah, I've my webcam connected via USB. My monitors connected via USB because my monitors acting as a USB hub. On the floor I've even got foot pedals that are connected via USB so that I can scroll using my feet rather than just my mouse. All very different devices but all connected to one type of connector.
So they're all connected to one port, in this case USB. They're all connected to. The boss on my computer, so the. The data bus is where all of these devices have to send that data. And that brings up another question. What happens if all of these things are happening at once? And of course, because they are very different devices, they all have different controllers and we looked at that last week or maybe the week before when we looked internally at hard disk and we saw that there wasn't just the desk and it's read arms, but there was actually some electronics there.
Those are there to control that device and you have similar things in most. And. Over devices. Make her controls CEPS. Codes, maybe even some memory to have a a cash or a buffer in there too. So all of these things, not surprisingly, all work in different ways for all these types of devices.
The controller for my USB thumb drive is very different to the controller from my USB mouse and very different to the controller from my foot pedal that just let me move through that and. That's late, look no hands. It's magic. So this is roughly how it will be set up. You've got your main boss, so this is for PC. The other things will be similar.
You have your main bus where all of your data is transferred so it all moves along here. No matter what type of device we have, so you might have and this is quite an old diagram. You probably don't have an IDE controller, but maybe E now? So you've got controller and that has, you know multiple connectors, so get one control hub multiple devices. Similar with cozy.
You can do. 7/8 SCSI devices, all with one controller. And you can also have Daisy Chain SCSI, so you can add more on to the end. We've got other types of interface that do other types of devices, like keyboards, and it's a while since anybody's had a serial port or a parallel port. 'cause it's mostly USP. No. But you'll notice also that as with USB, there's also an expansion bus. So just like how USB devices all our USB devices connect to one expansion bus that's connected to the interface, which in turn is connected to the PCI bus like everything else. So all of these things are connected to 1 device it to 1 bus no matter what the device says. All your graphics or we're procesos, everything and that can be an issue where you have lots of different connections all trying to do things at once.
I'm not seeing any questions in the comments. Don't forget if you have anything, just ask. Not surprisingly, all those different types of faces have lots of different types of hardware. So what we try and do is have a. I organs instructions that control the devices rather than seeing or, well, let's say, let's reinvent the wheel for every type of device. Let's just use the same instructions and let the device sort it out.
So we will say something like read some data. How that works on a hard disk? Feels like USB drive versus a keyboard. Leave that to the unique hardware. For the device, all we want to do is read some data. That suggests that we have some some support around that. So with things like registers to put the data that we read, and if you think back to your little man computer, you remember that even just reading a single.
I. Post box of memory. You remember that. Turn on my light or sorry hang on.
There we go. So you remember that when you read. A piece of data from memory. It works as we up this bus. And gets read into the register. We have this same sort of thing for IO devices. Still coming up the same bus. Still connected. Member, we've only got 1 bus.
But it's the same idea, so if your little man computer it was coming up blue bus and go into the processor. We will do the same thing when we're reading from other devices like hard disk control. Come on to the bus will get and. Close to CPU, NB stalled NR register. So registers for getting data hadn't registered. Putting the data out but also other registers to control it. Is this device currently being used?
That's quite important one, because if it's being used by 1 device, you probably by 1. The process you probably don't want another process getting access to it. If you are writing out data to a printer. From one application. You probably don't want another application to also trying simultaneously right to the printer 'cause all you do is you get add jumbled print. The same sort of thing would happen if we were trying to do any other device. Similar anyway.
We also have to decide how we are going to represent those devices. In our system. So you remember way back when we talked about CPUs CPUs have? Data bosses. So that's connected to this PCI bus, but they also have. Instruction. Posix.
And address buses. So if we want to get. And address. From memory we see which address we want. In this case it comes from the program counter that goes down the address lines. It says we want it from zero and it brings it back up. So the question becomes, do we do a similar sort of thing? 4. I would have AC's if we do then it's called memory mapped IO. In essence, we pretend any device that we have has got a memory location and if we want to write to that device, we just use the same instructions and write to a memory location knowing that act in actual fact it's an IO device.
So for example, to make this dot here. On the screen. Blue so that's blue and I oh what we will do is write to memory address 78214. And what will rate to that is a piece of data that represents blue. Which means that the hardware, in this case the the graphics adapter.
Will send information to the monitor to see make that particular pixel blue. But we have done that by writing data to memory. We don't do that if we want to write directly to the device, then we're going to need different instructions. We're actually going to say, well, this is an eye or instruction rather than just an instruction, so we may have different different mechanisms for that.
Memory mapped IO is quite common, and in fact if you have a PC, there are still memory map locations that are what we call well known. The list seem everywhere. So we've been talking about interrupts for. Weeks weeks. You can see there that the interrupt controller actually is at IO. Address 20 to 21. Hicks and all of these things. Like graphics and light printers and like whatever. All have well known devices.
There may have been recycled, so you can see that list there. We don't have many disk drives anymore without many floppy devices, but that'll have been reassigned. So it might not be the USB connector. OK, so we've got this stuff. We got it connected. Question then becomes, UM. How do we know? Whether or not the device.
Has something to tell us. So we're OK if we're telling the device something, but how do we know if the device has something to tell us? We're gonna need to come up with a way. Or understanding that the IO device has some input. Abby, do you know what that is? Adam, do you know what that is? Adam Taylor, do you know what that is? Andrei? Do you know what that is? Answer man, oh do you know what that is Ben? Do you know what that is Callum? Do you know what that is? Daniel, do you know what that is? Evan, do you know what that is? Fraser? Do you know what that is? Frida? Do you know what that is? Harry? Do you know what that is? Jennifer? Do you know what that is? Jordan? Do you know what that is? I was typing on the. Course I do.
OK, you can tell everybody else. Save mom. I'll drink my tea volatility but. I don't know. It's OK you were doing good. I was just leaving it. Alright thanks, I ask it. What I was doing. Is connected to your account. By the way, now you can broadcast to a specific device or room. Thanks Google. You could ask me to OK Google be quiet. Sometimes I, oh devices, committee spring until life when you don't want them to.
While I was doing the year was polling. I was going through all over you and saying do you have something for me? And I just go through you one after the other saying. Is there something you want? Most different to how we may do it. Normally is what I always say to you is to upper virtual hand or put a comment.
And to the chat. Or even just speak. So those are similar to two types of ways that we do it for IO where either have polling where I go round everyone over and check and see whether there's anything you want to say. Or we do enter Oates where you tell me that you've got something to see. I oh, devices work in the same way.
We can. Use polling. We go around each device saying do you have anything? Have you got some data that you need to to give me? No, that means you get her and everybody everybody gets a chance. But what happens if you've got a lot of devices or devices? Take awhile. So again, think about it like as being in the class.
I get to Abbie and I'll be has a really long question and it takes me ages to answer. With that, a may get ruined the class. And get down to Pablo. Publish forgotten we wanted to ask in the first place. So it's it's fair in one sense that we go through everybody. But it can mean that you miss somebody because by the time you've got to them, they've moved on and they've done something else.
Can you imagine what would happen if that was data that can't be replaced? So network information coming in so even some. Pressing on the keyboard and all of a sudden. You do not have. That information is lost completely. But it can be reasonable. Or if you've got fast devices, if you know exactly what's going on, so it's probably not a good idea if you've got. A device where you can add an extra devices extra IO devices to your computer. But if you know what's there and you can manage it and you're happy saying OK, we're going to give equal time. For example, it might still be OK. Most systems or use interrupts, and you know that 'cause we've been talking about interrupts for months now and it's the same kind of idea with and I would advice the CPU is busy doing something.
Penn State have been interrupted by another process. It's interrupted by a device. The device says I have some data Hello keyboard. Here somebody pressed a key. CPU's talks with its turn runs the interrupt handler for the keyboard, which runs to the keyboard, gets the character. And this is important. It does nothing whatsoever with that character other than store in a buffer, so it doesn't attempt to process it or use it all. It's doing is grabbing it and saving it somewhere for whatever is actually using the keyboard to do with, as it will when that happens, but it doesn't go to the. The other process that needs it, it simply does it as quickly as possible and gets back to the. Original.
Process because both said before we want interrupt handlers to be small, compact and fast as we can possibly make them. So one of the other things that we have on our bus. As well as address line in the death online. And the control lines about whether it's reader rate is and enter up line. So if a device wants something, it makes our enter up line hi. CPU interrupts. Runs interrupt handler and then goes back to what it was doing.
That brings up another question. If you can interrupt a process. But the interrupt handler is itself a process. Can you interrupt an interrupt? And the answer is maybe. What we tend to do is define some interrupts as being interruptible. And some as being uninterruptible.
If. For example, you've decided that some things are more important. That may require I am. Prioritization. You can make them. Excuse me, maskable or non maskable. If you have a maskable interrupt. You can ignore it. So you're saying cannot port and you get here for can, but we're not guaranteeing it. A non maskable interrupt will always get serviced depending of what you need it for.
OK, so would as another. We need a furnace in how we're setting this up. So what we end up is something like this and I know that's about we easily can go back and look at these. Hopefully you've got them open on your screen anyway. But what it's really saying is the CPU is busy working away doing stuff. It notices that the Interop line is going high, so initiates that IO. The IO completes in one of multiple ways it could be done fine. It's got the data, but it could have been an error it could have. Being complete, it could have been whatever.
Goes back. Ah, the CPU has now you transfer control to then dropped handler. It processes, it, returns and then resumes again. That will happen all the time. And we will have interrupts from all sorts of devices, as you know. Andrew prioritize them. So for example, for a. A painting class CPU.
We have enter Oates. Actually, in order of priority. And again, that's a wee bit we. So we have children 56 possible interrupts in their actually given. Names, so the first one is a divide error. All the way down. Page folks, so the page folks here, we have an issue with. May this data not being in memory is down at 14. Floating point errors.
These are all non maskable so the 1st, 32 or non maskable and the rest are maskable interrupts. So whole bunch of things I've known, maskable. We've decided that's what we want, or at least the CPU. Manufacturer has decided that's what they want and the space for a whole bunch more. Maskable once. And you can see the on that list.
We're also using the four exceptions. Things that have gone wrong. Debugs divide arrows, breakpoints and again this is one of those ones where you either a programmer or not, and if you know what I mean by a breakpoint, great. And if you don't. Uh. Tough. But you need to go online programming. So Interops will cover exceptions as well. How do we have crashes?
USB's removed without you saying that you're going to remove them, so system calls all that kinda stuff. Anybody any questions before we move on? No. OK, one of the issues that we have in.
Connecting all these devices is that we have one bus. And one processor. So the boss can take one word of data and remember award is whatever the. The basic unit as Ben, that CPU maybe 16 bit 32 or 64 bit, but one chunk of data. A certain number of bits. When you go and ask, for example your hard disk to get some data, it has to get a word at a time in. The CPU has to sort that. Get this what get the next want to get the next flight ticket the next month?
That's an issue because. While it's doing that does nothing else it can do. So we have something called DMA direct memory access and the idea is rather than the CPU staying in control of every single word. There's transferred. Instead. We can say up to. Transfer chunk of data. Now it makes a lot of sense for things like how discs where. You've got a lot of data that you're transferring at once.
So rather than saying, given the next World, give me the next word. You'll see. Give me four key of data. So you see, starting at this position, give me 4K of data and put it into memory. At this point go away and do it and let me know when you're done. Not surprisingly, using an interrupt. That makes much more sense. It means that the CPU can go on with other things. However.
It's costly because DM he has actually. A piece of hardware we actually have to create another controller to do a DMA. So it's helpful, but it's expensive. Just like all these other things that were spoken about over the weeks. It's stuff that you can use to make you go faster or better or whatever, but it costs. But it makes sense. CPU initiates a transfer, says how much where it's coming from, where it's going to go over and do it. And don't bother me until your done.
Huh brings up another issue, which is how the. I will devices are interfaced, how are we specifically connecting to them? 'cause there's lots of different devices, which suggests that there's lots of different ways that we can connect. Already a dent ified lots of the devices, so I identified a keyboard. Not surprisingly, that's a character stream. You get one character at a time. You don't get a whole block of 120 characters. You get one character, it's serial one, not acting.
We list with something like USB. It's a streamed thing. You only get one character at a time, one more time. Other things, such as how desks are block devices, so you go and get a two key blocker or 4K block or something like that. So that's one differentiator to get single character or do you get a block of data? Is it sequential like a tape drive? Or a keyboard? Or is it random access? Can you go anywhere 'cause I could decide that I want, uh?
Red Dot right in the middle of the screen right here. So it's random. I don't have to redraw the whole screen just to make that red dot appear. So you could be sequential or random access when you can get any fail that you want from a hard disk. Is it synchronous? So it's happening at the same time or is it asynchronous in that it can go and do it and you get told later? Or can you choose? Is the device able to be shield?
So you may have multiple processes all using the same hard disk. An old bringing in bits of data. Or does it need to be dedicated and I I used the example of the printer, you can't have multiple processes writing to the printer at same time. They have to go. There has to be dedicated to one up at team. It's also how fast they are. Whether you can only read to them. I only read from them like a keyboard or only write to them like my monitor or whether they are read, write like hard disks. Don't forget all these things and blue the other sort of things that you absolutely want to remember. But these are all the different types of device, so not surprising. Or get a whole pile of different. Uh connectors, so let's say roughly how it's set up. And the system. So we've got our kennel controlling everything.
With the Colonel also has a subsystem that's dedicated to Iowa. And that's what the device drivers connector. So we've got all these different device drivers, SCSI, keyboard, mouse and so on. Those specific device drivers are linked to specific device controls, so that's a device driver understands the hard way on the hardware understands the device driver. They work in tandem. So they work in tandem. Although belong here and each of these things has.
One or more devices attached to it. Or potentially you might not have anything attached to it. You may have a controller on the other yarn using. I could unplug all my USB devices. Doesn't mean the USB device controls going away, it just means I don't have any devices attached to it at that point. OK, so we can see how this all works together and with if any of these things goes.
As you probably have noticed, if something happens to your mouse driver. You have an issue. You can't use your mouse. Your mouse wasn't going anywhere, still lives. Your device controller hasn't gone anywhere. It's still there, but you can't talk to. Similar you can have the device driver on the. Operating system as long as you want. If you haven't plugged in your mouse, it won't do you much good. You need everything. To be there for all of this stuff to work.
OK, so we've got all these different types of characteristics. All these different types of devices and you can see there. Having some examples of how they're connected and what type of device they are. Either. Block Rahul. For getting the data while the memory mapped, or indeed whether the use network connections 'cause. Of course a lot of the things that we do these days connect via a network, so we need some sort of.
Similar. Controller and driver. To work over the network as well. And. That may be something like a socket or something like that, or talk a wee bit about those after. Most programming languages also have commands in the APIs to allow you to access these things, and there's a Unix one there.
So we can have blocked devices, character devices. Doesn't matter, will still probably have similar things to connect to them reads right or find a particular thing in it. Uhm? Somethings connect using a raw connection, so we don't do anything with a keyboard, we just get the raw data coming in. And then we'll work it.
All those as we sold last week? Or was it before might have some sort of structure put upon them, like a file system through hard disk. We also looked before about what would happen in. When multiple IO devices have to work together like. Uh, memory memories I oh device seems everything else. And it might have to connect to the hard disk, so we might have virtual memory or working together and that might use DMA.
To speed that up so you can see the whole these things, all these rebates that were getting to to work. They all fit together in the end. Even the network devices, so depending on what we have, so for example, you're doing a report on Windows, so you probably want to look at socket interfaces. Because the protocol. To connect over the network is different to how the network operates, which again, is what we'd expect 'cause we want to have these different layers and you guys are doing networking will be fully aware of the OS I layers. If you're not, go look up the waist size certainly or model and you have a good idea about how we separate out things like hardware. And information and connections and all that kind of stuff.
Because you might have very different things depending what you're sending. The whole thing we have to think about is how specifically this will work in terms of when things have transferred. Think back to that diagram with the bus and all the devices on it. What happens if? All the devices also. Yeah, I want to talk so you get one interrupt request and also I want to talk at once.
Well. You could have an issue. If everything is raised the I want to talk line. How do you know which device it was? And how do you know which one to go to 1st? So what we tend to have is a clock. So every CPU will have a clock. And it's just pumping away. So rather than things happening at random, things happen. Only tick of the clock.
So for now, your device wants to raise a connection. It will do it when the clock ticks. If more than one device tries to connect the both go oops or made a mistake in the back off. And we can put some things in there like. 'cause you know, Phil just backed off and went over going the next one. They know what would happen is they would all come in at the same one again. So we put things in like you back off for a random amount of time. Because before you connect you check to see if anyone else is using it. So if someone else is using it back off and then you comment on that clock tick.
So we need that to put some structure around these things to make sure that we don't all just talk at once. The. Same as if you see people using. Walkie talkies for the first time. And they will try and figure that have to do something to see the finished talking or they want to start talking. Like in our teams meeting. It was 60 of those in this meeting in everybody unmutes and starts talking at once. It's quite tricky. So you got your virtual hand and somebody says yet you, then you then you. It's exactly the same for IO. They bought their virtual hands and CPU says right on Eagle.
But if we're putting that in place and we're saying, yeah, you go, but you can't go. Is that sufficient for all the different types of devices that we have identified? Portable devices that require a lot of IO. Do we see? Uhm, right. While this I always going on nothing else happens.
So we're just waiting for the iota happen. That's called a blocking IO. Nothing else can go on until that. I always finished that drill is simple to implement. You Wale doing something you stop doing that thing in you do the IO. The IO finishes. You go back to doing what you were doing. Dead simple, but. Pretty slow and inefficient. So maybe you try to implement non blocking IO.
And your. Operating system. One where you say OK. Well, instead of just stopping. Why don't we take a wee bit and then go back and take a wee bit and go back so you get as much as you can? In one Tom, one cycle, if you like. And then. Tell you how much of. Transferred so you know that you have to go back. And of course, that then leads to the idea that, well, if you're just waiting and stuff to come back, do we even need to hang about waiting for that? Or do we just?
To somebody, just let us know when that's happened so we can have synchronous IO. Where we have. The IO is requested, it gets through the device driver on the interrupt handler and it gets the data transfer and all this. Takes time to eventually works its way back out. And the pill says this happened or or do we try and implement asynchronous so it gets a request? It works its way through the device and the interrupt handler you initiate the hardware data transfer.
While that's happening and remember how slow IO devices are compared to the CPU while that's going on and data is put into a buffer or in private, it's going to go. You want your way back up and going on or what. It's just keep going with the process. And then when that transfer has happened or by the way you've got some data, no. Do you want to use it? Clearly more difficult to implement. Put far better. In terms of.
Using your resources well. OK, anybody got any questions on that before we move on? OK, well that's been a wee while. So I think we probably need a rebate.
So where we take 10 minutes and I'll see you back here in 10. K So even then. Then
OK, and we're back. OK, anybody got any questions? I've thought about.
OK, if there's no questions. We'll get back to what we're talking about. OK, so we're just talking about synchronous and Asynchronous Island. Ah. So I went to move on to thinking about. The IO subsystems and some of the things that they will need to have in them.
2. Uh. Cope. With the sorts of things that we're going to have to throw out them. We've already touched on some of them already, so some of them may have to have scheduling, so you might have to schedule your access to something like a printer. Uh, to stop in economics up, but you may also want to schedule in order to ensure that everybody gets a goal. So when process starts to access a device and doesn't give it up. We might have an issue.
Another process is then can't get access to the data that they need to continue. Sometimes we actually implement that into the operating system to ensure. Fairness, and we call that quality of service. To ensure that each process gets a certain amount of the resource is, and that's guaranteed. Oh, things we have to implement our things like buffering.
So uhm. As we've spoken about, a lot of the devices. A very different, including in terms of how fast they are. So in essence, memory will take data as fast as you can throw at it along the bus, but. And you can't get the device for home, a USB drive as quickly as memory can take it, so you've got a choice. You either stop everything.
Wait until the slow USB drive or hard disk or whatever happens to be transfers all its data, or you put in. A buffer. Excuse me a buffer is just some memory that sits in between the device and the system. And takes the data from this very slow device. And stores it somewhere.
Excuse me until you're ready to pass it on, so you might have, for example, enough memory in the device controller for a hard disk. To store a whole block. So while we are busy getting the data just 4K or 8K block from the hard disk. It doesn't go anywhere until you fill up the buffer at that point. The device then says I'm ready to transfer data and the data is then transferred as fast as the bus can cope with it.
It also helps in terms of, uh. Devices where you have. Different sizes of data that you're transferring. I mentioned earlier that the keyboard will have a buffer. So the. Single character that you get there. You probably don't want to do anything with it at that point. 'cause all things you could be getting on with. Based on the Minibuffer until the until you're ready with them.
Buffering also helps with something called copy semantics, and this is one of those programming things that I'm not going to go into detail. Feel free to Google it and look up copy semantics, but uhm. In very short and not particularly accurate terms, what we're really talking about is if you have data in two places, who wins. So if you've opened it and copied it, who's who's gonna win?
That might mean that you have double buffers 2 copies. Kim might have it, user might have it. Buffer might have it. Uh, so you need to be careful. You need to understand. Put your version is elitist. Particularly if data has changed and need to save it back it again. So at some of the stuff we need to support other things we might want or things like device status tables. So we have a list of all the devices that we have. Came. Connected to system. And. Who's using them? So you see the other the printer has had a request.
For assessment data. The desk has had two requests. For data at different places and different lengths. So we'll keep a note. Of who's needn't stuff and Wayne and we may want to do something with that same as we did before, so you'll see there. Those two requests, ones for 20,000 bytes, once for 500 bytes. And even though the 20,000 bait one came in fast. Maybe it's better to access to 500 bytes, get out the way and it's the same sort of stuff that we were talking about in previous weeks in terms of best algorithms to to support these.
And of course, a different algorithms may be different for different devices because we have such a desperate range of devices with our district. Safe speeds. All the way down from my keyboard. Through to the system bus. And we have to be able to cope with all of these. All the things that we might want to have our things like caching. So that I am.
Game was spoken about this before. If we get data from. A device we may want to get a bit more data if we can. On the basis that the next thing will last for wasn't next thing. Yeah, that's coming after. So maybe we keep a cache. So that rather than having to go back to the very very slow device. We go to fast memory cache. So it can speed up quite a bit. Uhm, certain we may actually implement all of these things at once, so the device may have a buffer and that data that might then be held in a cache.
And then transferred to memory. So we we always need to be very careful 'cause it could be in memory. And the cash and the buffer. And on the device simultaneously. So we need to be sure which one we are working with and which one and particular where we've changed things. Which ones need to be saved back? And a similar idea, but working serially is something called spilling. So if we have a very slow printer for example.
We don't want to wait on the printer. We want the process to be able to create a file. Which is what it ends up being. Uh. You create. The file, which is what the printer is looking for. That's the input into a spool queue. And the printer then takes those fails. And prints them off. Love Fail is a specific format for the failed, so it's late. You're printing to it, but it takes all the.
The characters and everything else that you need to make that thing come out of the printer. Ah. You may also have. Teams where you reserve a device so you make it in. Available to just one process. Bot that can cause issues as well, particularly with something called deadlock. Now if you remember back, there's a chapter on deadlock and we jumped over it, so I don't want to go into too much detail what you can.
How you might want to think about it is. If you have your driving on a road and you come to a roundabout. And those three cows get to the roundabout. As you know you give way.
To the car on the right. So this car is giving we to this car. This car is getting ready to this car and this car is getting weed in this car. Which hasn't Tom giving away. To that car which is giving me to that car which is giving way to that car which is giving way to that car. But that's a deadlock. Similar things in half in a computer system. We are. Uh. Somethings waiting to user. Defesa process is waiting to user device. But that's hailed by something else. But the two processes are working together, so the process is waiting for data. From the other process, and it can't get it because the original process is holding the device and it can't get the data to pass through the first process and you get this deadlock or fear.
So you need to be very careful where you reserve data. Hey where you reserve devices to particular processes? We also have to put in. Stuff to handle errors. What happens if we can't get the data? What happens if we have a read error or right here to be retry? What happens? How many times are there different things depending whether it's reader right? What is our? They didn't.
What's our process for doing all of these things? And at which point do you start reporting them? If you have a reader from how dusty you just go right will keep reading until we get it. Or do you do something else? So some. A device controls for hub disk, for example will mark certain blocks as being bad because they've reached our limit on how many times you've tried to access. Not just say don't use them. So development of the. They use space and free space that we've looked at before will have a do not use space.
What happens if you get loads of those? Does the device just keep doing it, or does it at some point report that back? So do you put in a log that says look, we have an issue with this device? You may want to look at it. We also need to protect the IO because again, as we've seen before, for things like memory, badly behaved processes might try and access things. Ah. Not by using the operating system, but by going straight to them.
So we talked about it in terms of memory and processes, accessing memory that are used by other process is the same thing can happen with IO. It can try a process can try and run and IO command not through the operating system using purple system calls, but instead going straight to it. So we need to protect that and we need to make sure that all the IO connections go through systems. Controlled by the operating system controlled by the kernel. It hasn't rusted bypass. Those is simply blocked.
So the Campbells got a key role to play in all this. It's got to remember all this stuff. Got to know all the devices. It's got to know what's been used by which process and where it's got to know what's connected and what's disconnected, and what the devices are and how fast it can go and what type they are and whether they can get in lots of staff or whether it's got a buffer. All of this stuff, so there's a whole pile. Move stuff set in the background, all to keep track of all of these things.

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