Something missing from this kernel interface?

Discussions on more advanced topics such as monolithic vs micro-kernels, transactional memory models, and paging vs segmentation should go here. Use this forum to expand and improve the wiki!
Post Reply
Craze Frog
Member
Member
Posts: 368
Joined: Sun Sep 23, 2007 4:52 am

Something missing from this kernel interface?

Post 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.
Last edited by Craze Frog on Mon Jan 07, 2008 3:55 pm, edited 1 time in total.
User avatar
Combuster
Member
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:

Post by Combuster »

anything error-handling related?
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
bewing
Member
Member
Posts: 1401
Joined: Wed Feb 07, 2007 1:45 pm
Location: Eugene, OR, US

Post 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.
Craze Frog
Member
Member
Posts: 368
Joined: Sun Sep 23, 2007 4:52 am

Post 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.
Post Reply