Just checking...
Posted: Wed Jun 06, 2012 9:06 am
Hi, so I am about to start what I believe is the final hurdle in making a simple kernel: loading and executing an application, and I just want to check a few things before I head right in and get lost in page faults (hopefully not )
Firstly, am I correct in thinking that, according to the kernel, memory (possibly) looks a bit like this:
where A and B are applications. But according to some application A, it looks like this (thanks to paging):
Then is it correct that to start running an application I should:
1 ) Fork to make a new thread
2 ) Allocate some memory for and load my application, possibly putting .text and .data sections where the file format asks.
3 ) Allocate a new, blank stack
4 ) Push onto the new stack the addr of a kill_thread() function
5 ) Push onto the new stack the arguments sent to the application
6 ) Switch to new stack
7 ) Enter user mode
8 ) jmp to the beginning of the process code.
Many thanks,
Firstly, am I correct in thinking that, according to the kernel, memory (possibly) looks a bit like this:
Code: Select all
+--------------------------------------------------------------+
|Kernel code|Kernel heap|Alloced to A|Alloced to B|Alloced to A|
+--------------------------------------------------------------+
Code: Select all
+-------------------------------------------------------------+
|Kernel code|Kernel heap|Alloced to A|Alloced to A|Blank |
+-------------------------------------------------------------+
1 ) Fork to make a new thread
2 ) Allocate some memory for and load my application, possibly putting .text and .data sections where the file format asks.
3 ) Allocate a new, blank stack
4 ) Push onto the new stack the addr of a kill_thread() function
5 ) Push onto the new stack the arguments sent to the application
6 ) Switch to new stack
7 ) Enter user mode
8 ) jmp to the beginning of the process code.
Many thanks,