The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
+17 votes
2.6k views

Normally user programs are prevented from handling I/O directly by I/O instructions in them. For CPUs having explicit I/O instructions, such I/O protection is ensured by having the I/O instruction privileged. In a CPU with memory mapped I/O, there is no explicit I/O instruction. Which one of the following is true for a CPU with memory mapped I/O?

  1. I/O protection is ensured by operating system routine(s)

  2. I/O protection is ensured by a hardware trap

  3. I/O protection is ensured during system configuration

  4. I/O protection is not possible

  • 🚩 Edit necessary | 👮 Gupta731 | 💬 “Out of syllabus now”
asked in Operating System by Veteran (59.7k points) 1 flag | 2.6k views
0
Please confirm this answer between options a) & b)      @Bikram sir
+4

@Tuhin

It is option A , is correct.

see this line 

Normally user programs are prevented from handling I/O directly by I/O instructions in them , For CPUs having explicit I/O instructions, such I/O protection is ensured by having the I/O instruction privileged.

this means explicit I/O is done at kernel mode , it can not done in user mode.

In a CPU with memory mapped I/O, there is no explicit I/O instruction so protection is ensured by operating system routines only . As in kernel mode only OS can handle the task . And Kernal mode deals with system calls. So option A is appropriate here ..

+1
@Tuhin datta trap is a software signal raised during errors in the code not for I/O SO B IS WRONG
0
@Bikram So in isolated IO, IO protection is ensured by hardware trap as in option B?
0
@Bikram sir, I think option B is correct. Following is the explanation(please correct me if I am wrong).

In case of CPU with explicit I/O instruction, protection is provided by having I/O instruction privileged. So that if user process executes an I/O instruction then it will result in a hardware trap as it is not in kernel mode.

Now,  thinking in the same line if we consider case of memory mapped I/O. Here we have some address range which is used to access I/O device, so we can do I/O operation by simple memory access operations. Now, in order to provide I/O protection we should not allow any user process to access that region of address. This can be implemented by using two registers (limit and base), such that if any address produced by a user process lies between  limit and base then it produces a harware trap. But if it is accessed by kernel process then it should not result in a trap (as it is kernel mode).

ultimately in both cases we want to protect user process from directly doing I/O, and we want it to leave off burden of doing I/O task to os.

2 Answers

+30 votes
Best answer

Option (A). User applications are not allowed to perform I/O in user mode - All I/O requests are handled through system calls that must be performed in kernel mode.

answered by Boss (13.5k points) 1 flag:
✌ Edit necessary (Gupta731 “Out of syllabus now”)

edited by
+2
How is I/O protection ensured by CPU having isolated mapped I/O?
+2
When it comes to memory mapped IO, a simple LOAD instruction can read the address range mapped to any IO device, right ? So if I am correct a non-IO instruction will be able to read from device. I agree with the above option, but the explanition does not seem correct
+5

Registered user 31  

Explanation given is correct too ..

From question , it is clear that user can not handle I/O execution.So I/O is perform at kernel mode only ..

  • The kernel  is a trusted software to OS, but all other programs are considered un-trusted software.
  • Thus, all user mode software must request use of the kernel by means of a system call in order to perform privileged instructions, such as process creation or input/output operations. 

Read https://gateoverflow.in/94643/user-and-kernel-mdoe

+2
User cannot handle I/O protection directly. It is handles by program (or routine) of OS
0 votes
B)

Since the IO instructions are not explicit in memory mapped IO, OS can't know just by seeing the instruction that whether it's an IO instruction or memory instruction. Thus when address space belongs to IO devices it triggers a hardware trap which makes the CPU aware that this is an IO instruction.
answered by Active (2.6k points)
+1

A trap usually results in a switch to kernel mode, wherein the operating system performs some action before returning control to the originating process.. a type of synchronous interrupt typically caused by an exceptional condition .

Trap is more like an exception... so I/O protection can not be hardware trap.

Answer:

Related questions



Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true

44,297 questions
49,785 answers
164,370 comments
65,857 users