0
$\begingroup$

By my understanding, operating system is the abstraction layer above hardware. Which means that an operating system that supports two different CPU architectures can run the same code. But I still cant understand the details/steps of executing a given program.

Suppose, I have a program that takes 2 numbers from the user, adds them and displays the answer. There are few steps in which the program does its work (Might be missing something or wrong somewhere, feel free to correct):

1) Double clicking the program file icon.

(a) How do the GUI and the mouse (and RAM) interact to identify which icon is clicked?

2) Loading of program in the Main memory using the address of the icon clicked.

(b) How is the os involved in finding that file from the disk?

3) Input of 2 numbers (CPU reads instructions of taking input from keyboard).

(c) Will the example of 2 different keyboards (For eg: one with 'fn' key like in laptops and one of full size) be a good example for explaining the need of device controllers and drivers?

4) Adding of the 2 numbers (Arithmetic operations).

(d) Is the os responsible for providing the CPU with the addresses of the operands and operators?

5) Displaying the output on the monitor.

I understand that the question might be broad, but I am not able to piece together all these things just by reading books (like 'Operating System Concepts by Galvin').

Also, I like as much detail as possible as it makes things more clear.

$\endgroup$

2 Answers 2

1
$\begingroup$

At one level you have hardware: A computer with a CPU, RAM, hard drive, graphics card, monitor, keyboard and so on.

Then on the lowest level of the operating system you have code that can talk to these devices. That code allows the operating system to read or write data from the hard drive, determine the location of the mouse, and so on.

At a higher level of the operating system, the OS has code to assign address space to processes, start processes and kill them, allow these processes indirect access to the hardware.

Above that, it is just code. You have a mouse reporting it's location, you have graphics hardware that can display a cursor, so someone wrote code that keeps track of the mouse location and displays the cursor at the point corresponding to the mouse location. And then someone wrote code to display icons. And more and more and more code on top of that. And that's all, really.

$\endgroup$
0
$\begingroup$

Everything I will say does not represent the real thing but gives a taste of what is happening.

A computer is manufactured in a way with a pre installed “program” which is responsible of transferring electrical current to all the parts, cpu, hard drive, gpu, etc. This is binary logic.

Each one of the components, cpu, gpu, hard drive, mouse, keyboard has a really long documentation of how is it working. For example the mouse input is the “speed of lazer signal” and the output is just a string of 0 and 1s. Of course there are plenty of protocols for such kind of communications and this is what drivers are used for.

Now, the operating system comes and solves all these long documentations and interactions between the different components of your computer.

You can think of an OS as a huge monolithic while loop.
while True:
check the mouse if user clicked or moved
check the keyboard for keystrokes
check the network card if it receives messages
check the GUI if it needs to be refreshed
check for any interruption
...
etc

Of course many events are not handled on software level but there is special hardware for this case. For example the hardware CPU may have certain interruptions when devision by zero is encountered.

The main job of an OS is to enorchestrate all the communication between the components, but the story does not end here. A main job of the OS is also to forbid the user of accessing several locations of the hardware which may cause dis function. Also, it gives the power of parallelization of your applications. Imagine having to wait finishing a youtube video before printing a document on your printer.

$\endgroup$

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.