-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor kernel memory usage #183
base: master
Are you sure you want to change the base?
Conversation
process_table Pointer to process table in the heap | ||
active_processes Number of active processes | ||
current_process Index of the currently running process | ||
last_pid The last PID allocated by the kernel |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These variables are currently called threadTable
, activeThreads
, currentThreadIndex
, and lastThreadID
. Part of this change is to rename all of the kernel internal memory to use snake_case. Also, note that threadTable
is a fixed address currently - you'll have to stick two bytes of memory somewhere in the kernel state and update code that refers to threadTable to read that instead.
d8395a9
to
64ead7e
Compare
0x0006 0x02 Pointer to file handle table | ||
0x0008 0x02 Pointer to library handle table | ||
0x000A 0x02 Pointer to signal table | ||
0x000C 0x03 Reserved for future use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that the length of a process entry has changed.
1: EoF if 1 | ||
2: Flushed if 1 | ||
3: Set if final block of the file* | ||
4-7: Reserved for future use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previously, flags were split across two different parts of the file handle entry, because I was lazy. This merges the flags into one byte (since we don't need owner any more) and rearranges them a bit with future changes in mind.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why was owner needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To identify which thread owned the file. It was necessary when all file handles were in one table, but now that each process is going to have its own file handle table it's not necessary.
64ead7e
to
85fe8a5
Compare
|
||
0x0000 0x02 Signal handler | ||
0x0002 0x01 Signal number | ||
0x0003 0x01 Reserved for future use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Signals will have to change to be more Unix-like, and some userspace programs may have to change to compensate for this (and some syscalls too). createSignal
and readSignal
will have to be removed and replaced with signal
and kill
, which should behave like their POSIX counterparts.
Lots of places in the kernel (and some places in userspace) have to change for each of these changes. I suggest taking it slowly and breaking this up into smaller changes that you can do and test separately. |
All references to threads should be replaced with processes. We'll sort something out for distinguishing threads from processes later, it will be something fairly lightweight. Also, threadlist should be changed to use http://www.knightos.org/documentation/reference/threading.html#getNextThreadID instead of accessing kernel memory directly. |
cc @np511
This currently only contains documentation updates.