Why should "accessing I/O device" be a privileged instruction?

While studying Operating System Concepts, 9th Edition, I got stuck in Exercise #1.6. 1.6 Which of the following instructions should be privileged? a. Set value of timer. b. Read the clock. c. Clear memory. d. Issue a trap instruction. e. Turn off interrupts. f. Modify entries in device-status table. g. Switch from user to kernel mode. h. Access I/O device. Answer: The following operations need to be privileged: Set value of timer, clear memory, turn off interrupts,modify entries in device-status table, access I/O device. The rest can be performed in user mode. Why should "accessing I/O device" be a privileged instruction?

925 10 10 silver badges 18 18 bronze badges asked Mar 13, 2014 at 11:49 user3415167 user3415167 1,013 2 2 gold badges 13 13 silver badges 23 23 bronze badges

4 Answers 4

Modern OS provides minimum two modes of operation: user mode and supervisory mode. This is possible with some hardware support (for example special mode bit in hardware to indicate one of the two possible modes). Privileged instructions (that can possibly harm the system when executed by malicious process) can be executed only in supervisory mode. I/o instruction falls in this category and are entrusted to OS. These can only be called using system calls. Whenever user process needs any I/O operation it invokes appropriate system call. Whenever a system call is executed, it first sets mode bit to 0 (supervisory mode) and then executes the call. before exiting from the I/O system call, it sets the bit to one (user mode) and transfers control back to user process. The idea is not to give the supervisory control to any user process.

If I/O instructions are entrusted to users, they may misuse them(e.g.overwriting FAT entries, or destroying important disk data). Now I/O instructions are privileged so that, OS could check whether you are authorized to do that I/O operation or not, before performing I/O.

answered Nov 2, 2017 at 17:41 Kishor Bhoyar Kishor Bhoyar 121 1 1 gold badge 1 1 silver badge 6 6 bronze badges

Reading/writing to a device will interfere with other processes (think some rogue process reading from the keyboard while passwords are being typed in. ).

answered Mar 13, 2014 at 11:52 11.7k 8 8 gold badges 34 34 silver badges 53 53 bronze badges

Disk read / write operations are all carried out by I/O instructions; without their being privileged, a user program can write into the disk thereby destroying all the disk resident OS, other application programs, etc.

answered May 2, 2016 at 7:28 Dipankar Sarkar Dipankar Sarkar 1 1 1 bronze badge

In some systems, this idea is carried to an extreme, and pieces of what is traditionally considered to be the operating system (such as the file system) run in user space. In such systems, it is difficult to draw a clear boundary.

Modern Operating Systems 4th Edition--Andrew Tanenbaum

answered Jul 4, 2021 at 3:50 3,549 1 1 gold badge 33 33 silver badges 46 46 bronze badges

Related

Hot Network Questions

Subscribe to RSS

Question feed

To subscribe to this RSS feed, copy and paste this URL into your RSS reader.

Site design / logo © 2024 Stack Exchange Inc; user contributions licensed under CC BY-SA . rev 2024.9.4.14806