0

I was listening to OS lecture, and got confused by these two phrases.

  1. "When a user process calls IO, it invokes a system call and waits until system call is finished"
  2. "When a user process invokes a system call, the user process itself executes the kernel function in the kernel mode"

I believed that a user process invokes system call to use the IO, the kernel executes the kernel instructions, while kernel is running user process waits until the IO process is finished. So I thought phrase 2 must be wrong. But professor said both are correct. Can someone help me understand why?

3
  • 2
    "a user process invokes system call to use the IO, the kernel executes the kernel instructions" - Kernel executes instructions in the context of some process. In many OS'es a user process and the kernel process, which processes syscalls, are the same processes. This is why the second phrase is correct too. Commented Apr 2, 2019 at 11:21
  • @Tsyvarev Let me make it clear. In view of processes, the kernel instructions are executed in the same process so second phrase is correct? Commented Apr 2, 2019 at 12:26
  • Yes, exactly so. Commented Apr 2, 2019 at 12:29

1 Answer 1

1

Actually, both are only correct sometimes.

"When a user process calls IO, it invokes a system call and waits until system call is finished"

That's only true if the system service does synchronous I/O. Some operating system have asynchronous I/O calls that do not cause a wait.

"When a user process invokes a system call, the user process itself executes the kernel function in the kernel mode"

That is true when the system implements all its system services in kernel mode. Some system have multiple modes (often 4) that allow implementing system services that cannot possibly crash the system.

In any event, this might not be a synchronous I/O system service call. In that case, it might not wait. If you call a time system service, it is unlikely that your process will wait.

Sign up to request clarification or add additional context in comments.

3 Comments

So a system can have a "safe kernel" mode allowing user processes to run some kernel instructions?
No. It is common to have 4 processor modes outside the wacky world of Intel. So you can have system memory that is open to these modes. Generally you cannot execute privileged instruction in these intermediate modes.
WIKI Link: You can learn more about multiple CPU mode systems here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.