i’m studying for a test is OS (unix is our model).
i have the following question:
which of the following 2 does NOT cause the user’s program to stop and to switch to OS code?
A. the program found an error and is
printing it to the screen.B. the program allocated memory that
will be read later on from the disk.
well, i have answers, however, i’m not sure how good they are.
they say the answer is B.
but, B is when the user uses malloc which is a system call no? allocating memory doesn’t go through the OS?
and why printing to the screen should need the OS for it?
thanks for your help
In A the user program is responsible for detecting the error and deciding how to provide that information. However in most cases actually rendering characters to a display device or terminal will involve an OS call at some point.
In B the OS is certainly responsible for memory management, and allocation may at some point request memory from the OS or the OS may have to provide disk swapping.
So the answer is probably strictly neither. But A will require a system call, whereas B may require a system call.