Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Refactor kernel memory usage #183

wants to merge 1 commit into from

Conversation

ddevault
Copy link
Member

cc @np511

This currently only contains documentation updates.

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
Copy link
Member Author

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.

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
Copy link
Member Author

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
Copy link
Member Author

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.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was owner needed?

Copy link
Member Author

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.


0x0000 0x02 Signal handler
0x0002 0x01 Signal number
0x0003 0x01 Reserved for future use
Copy link
Member Author

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.

@ddevault
Copy link
Member Author

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.

@ddevault
Copy link
Member Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants