Hi everybody,
I have been working on my kernel for few weeks now.I have just completed my memory manager recently.I need to clarifie some issues ; here is what i have done in memory manager
top level - malloc()
middle level - memory_mapper()
bottom - physical_frame_allocate().
1)malloc () - simple bin approach.starts allocation from 0xC0000000.
2)memory_mapper() - asks os for memory and maps this memory to the end of Heap(stating from 0XC0000000).( I have set 1023rd entry of page directory to itself so that i can manipulate physical address once paging is enabled)
3)physical_frame_allocate() - simple bitmap approach.memory_mapper() asks this function to supply pages.
These are for kernel code. and are working fine.Is writing memory manager for application layer code any different from this .I have been thinking
1) exact same methods except user heap starts from say 2 gb mark and
2) level bit in frame is set to user level.
would this suffice ??
Question 2) I have read James tutorial for multitasking. Is there some other way for copying stack to different location.( Handling esp and ebp )
question 3) How does kernel knows if a process has ended if process do not call exit() explicitly.I have read that compilers places exit() call at end but what if system call is implemented by some different name?What does DJGPP add in such cases ?
Multitasking , Memory Management and Process Cleanup
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: Multitasking , Memory Management and Process Cleanup
Generally, moving a stack is a bad idea since there's no way to make sure everything points to the new stack rather than the old stack (and not corrupt things in the process)Duleb wrote:Question 2) I have read James tutorial for multitasking. Is there some other way for copying stack to different location.( Handling esp and ebp )
The compiler doesn't. The C library does.question 3) How does kernel knows if a process has ended if process do not call exit() explicitly.I have read that compilers places exit() call at end but what if system call is implemented by some different name?What does DJGPP add in such cases ?
When you link an application, it includes the C runtime (commonly in the form of crt0.o, crtbegin.o and crtend.o). what crt0 does (and looks like) is this:
Code: Select all
entry:
// do some setup (opening stdin, stdout, global c++ constructors)
call main
// do some cleanup (atexit, closing files, c++ destructors)
call exit
Re: Multitasking , Memory Management and Process Cleanup
Question 3). My kernel currently supports only ELF 32Bit Exes. The Loader inserts an Entry /Exit code(small startup function) into the executable memory image and modifies ELF Entry Address to point to this stattup function. So, if the process /user program completes gracefully, control comes back to this startup function which then calls EXIT API
complexity is the core of simplicity