- Aug 12, 2014
- 522
- 3
- 81
Hello everyone,
Here's what I mean:
I wrote an assembly program running on Linux that simply puts the string "Hello!" on the screen in the terminal window from where the program is run.
I compiled, linked, and ran it with no problems.
Then, I added this function to the source code:
crash:
push 5
ret
and called this function right before making the screen-write software interrupt.
I compiled, and linked it with no problems.
When I ran it, the words 'segmentation fault' popped up on the screen and the process terminated.
This is to be expected; it's what I intended to do.
But, here's my question:
How did the OS pass this data to the process when the process wasn't expecting it?
I asked a question a couple of weeks ago about attaching event handlers to processes at the machine level.
The answer I received was that processes poll the OS and check for messages left in a queue for that process and then take appropriate action when a message has been detected.
But, you have to tell a process to check for messages.
In my example, there was no instruction to tell the process to check for messages from the OS.
So, how did the OS pass that segmentation fault data to my process for display?
Unless, it wasn't my process that put that string on the screen.
Maybe, my process was terminated by the OS before the data was placed on the screen, and the OS passed a message to the terminal window which is itself a process running in user space.
I would expect the terminal window process to check for messages from the OS as its sole purpose is communication with the OS.
What do you guys think?
Thanks.
Here's what I mean:
I wrote an assembly program running on Linux that simply puts the string "Hello!" on the screen in the terminal window from where the program is run.
I compiled, linked, and ran it with no problems.
Then, I added this function to the source code:
crash:
push 5
ret
and called this function right before making the screen-write software interrupt.
I compiled, and linked it with no problems.
When I ran it, the words 'segmentation fault' popped up on the screen and the process terminated.
This is to be expected; it's what I intended to do.
But, here's my question:
How did the OS pass this data to the process when the process wasn't expecting it?
I asked a question a couple of weeks ago about attaching event handlers to processes at the machine level.
The answer I received was that processes poll the OS and check for messages left in a queue for that process and then take appropriate action when a message has been detected.
But, you have to tell a process to check for messages.
In my example, there was no instruction to tell the process to check for messages from the OS.
So, how did the OS pass that segmentation fault data to my process for display?
Unless, it wasn't my process that put that string on the screen.
Maybe, my process was terminated by the OS before the data was placed on the screen, and the OS passed a message to the terminal window which is itself a process running in user space.
I would expect the terminal window process to check for messages from the OS as its sole purpose is communication with the OS.
What do you guys think?
Thanks.