Commit Graph

616 Commits

Author SHA1 Message Date
Andreas Kling
aa6d06b47e Use ELF program headers to load executables smarter.
This turned out way better than the old code. ELF loading is now quite
straightforward, and we don't need the weird concept of subregions anymore.

Next step is to respect the is_writable flag.
2018-11-03 11:29:30 +01:00
Andreas Kling
dd060d0fa8 Share code between spawn() and exec() implementations.
Okay, now there's only one ELF loading client in the process launch code.
2018-11-03 10:55:02 +01:00
Andreas Kling
c5eec9cbfc Factor out the "non-syscall" parts of sys$execve() into exec().
..to prepare for sharing code with createUserProcess().
2018-11-03 10:20:23 +01:00
Andreas Kling
202bdb553c Implemented sys$execve().
It's really crufty, but it basically works!
2018-11-03 01:51:42 +01:00
Andreas Kling
8accc92c3c Implement fork()!
This is quite cool! The syscall entry point plumbs the register dump
down to sys$fork(), which uses it to set up the child process's TSS
in order to resume execution right after the int 0x80 fork() call. :^)

This works pretty well, although there is some problem with the kernel
alias mappings used to clone the parent process's regions. If I disable
the MM::release_page_directory() code, there's no problem. Probably there's
a premature freeing of a physical page somehow.
2018-11-02 20:41:58 +01:00
Andreas Kling
10b666f69a Basic ^C interrupt implementation.
For testing, I made cat put itself into a new process group.
This should eventually be done by sh between fork() and exec().
2018-11-02 14:06:48 +01:00
Andreas Kling
621217ffeb Add tcsetpgrp()+tcgetpgrp().
One more step on the path to being able to ^C a runaway process. :^)
2018-11-02 13:14:25 +01:00
Andreas Kling
d8f0dd6f3b Start working on sessions and process groups. 2018-11-02 12:56:51 +01:00
Andreas Kling
90ddbca127 Free physical pages allocated for a process's page directory on exit.
Also use a ProcessPagingScope instead of region aliasing to implement
create-process ELF loading.
2018-11-01 23:08:10 +01:00
Andreas Kling
c70afd045e Use a freelist for GDT entries.
Tweak the kmalloc space layout a bit. Get the spawn stress test up
and running again.
2018-11-01 16:23:12 +01:00
Andreas Kling
52607aa086 Allow processes to go into a BeingInspected state (used by procfs.)
This ensures that the process won't get scheduled, and so inspecting
it is safe and easy without blocking interrupts.
2018-11-01 14:21:02 +01:00
Andreas Kling
fd03776443 Add a /proc/PID/fds text files that lists all the fds open in a process. 2018-11-01 14:00:28 +01:00
Andreas Kling
065f0aee35 Preallocate the maximum number of FileHandle pointers (fds) in every process.
This could even use a more specific data structure since it doesn't need the
grow/shrink capabilities of a vector.
2018-11-01 13:39:28 +01:00
Andreas Kling
fce81d376c Move Region and Subregion out of Process and make them free classes. 2018-11-01 13:21:02 +01:00
Andreas Kling
3e532ac7b6 Process now maps regions immediately when they are allocated.
This avoids having to do a separate MM.mapRegionsForTask() pass.

Also, more Task => Process renaming that I apparently hadn't saved yet.
2018-11-01 13:15:46 +01:00
Andreas Kling
4e60551aec Rename Task to Process. 2018-11-01 13:10:12 +01:00