Page 1 of 1

Something missing from this kernel interface?

Posted: Sun Jan 06, 2008 1:20 pm
by Craze Frog
This is the interface I want my kernel to have. Did I forget something?

Messages

Code: Select all

port_t ki_port_create(tick_t max_response_time, cb * callback);
bool ki_port_destroy(port_t port);
bool ki_send_message(port_t port, int aParam, int bParam, int cParam, int dParam);
void ki_get_message();
Processes

Code: Select all

handle ki_process_create(bool is_driver);
bool ki_process_destroy(handle process);
handle ki_process_get_current();
Threads

Code: Select all

handle ki_thread_create(handle process, void * entrypoint, void * stack);
bool ki_thread_pause(handle thread);
bool ki_thread_resume(handle thread);
bool ki_thread_destroy(handle thread);
handle ki_thread_get_current();
Memory allocation

Code: Select all

void * ki_page_alloc(handle process, void * page);
bool ki_page_free(handle process, void * page);
Memory sharing

Code: Select all

void * ki_write_process_memory(handle process, void * source, void * otarget, size_t bytes);
void * ki_read_process_memory(handle process, void * osource, void * target, size_t bytes);
void * ki_copy_process_memory(handle pfrom, handle pto, void *osource, void * otarget, size_t bytes);
void * ki_move_process_memory(handle pfrom, handle pto, void *osource, void * otarget, size_t bytes);
Note: On writing/copying/moving, the page table entries for the target process are managed automatically.

Edit:

Synchronization

Code: Select all

mutex_t ki_mutex_create();
void ki_mutex_destroy(mutex_t mutex);
void ki_mutex_lock(mutex_t mutex);
bool ki_mutex_try_lock(mutex_t mutex);
bool ki_mutex_unlock(mutex_t mutex);

bool ki_timer_wait(uint time);
Security
The message API can be accessed by all processes. (Processes can only destroy their own ports.)
The synchronization API can be accessed by all processes.
All other APIs can only be accessed by the root task.

Posted: Sun Jan 06, 2008 4:08 pm
by Combuster
anything error-handling related?

Posted: Mon Jan 07, 2008 3:11 pm
by bewing
It's not vital to the functionality of your OS, but I'd think:

thread_yield -- to just relinquish one timeslice
thread_priority -- don't you need to set priority somehow?
process_priority -- to inherit to all child threads?

and it's always nice to be able to get informational data back out of the kernel/executives, about the overall state of the system:

job_info -- current and statistical job table status
vmem_info -- memory usage/pagefault statistics
ipc_info -- statistical info about message queues/shared mem/"ports", etc.

Posted: Mon Jan 07, 2008 3:45 pm
by Craze Frog
Error handling goes through the messaging system for the moment.
I actually forgot about the yield, and that reminded me of a lot of other stuff, thanks for that.

Edit: I updated with a synchronization api. A timer wait with time = 0 will yield.