keyvank / zincos

A lightweight and readable C++11 Operating System!
23 stars 1 forks source link

Event Based Things #1

Open adminy opened 6 years ago

adminy commented 6 years ago

https://github.com/keyvank/zincos/blob/5b189efcd025c4328f3583093aed4569af3f0623/user/progress_bar.cpp#L9

Hahaha, Incredibly Good Code x'D Made my day. Now I wonder how timer based events get called. Maybe you can communicate in code with the system clock?

keyvank commented 6 years ago

:rofl: I guess you can implement the Sleeping functionality by adding a unsigned wait property to the thread struct, which holds the amount of time the thread needs to wait before getting scheduled again, and reduce this amount in every timer interrupt, according to the timer frequency.

adminy commented 6 years ago

It’s better making it callback based Instead with control of the when the process time it’s being called using the timer as you say but maybe making it so that a specific process can take care of timed callbacks. Or let a process have the API of calling other processes on a given time. I guess I’m thinking about it too high level. On a lower level it’s probably lots of noops indling the cpu away.