-
Notifications
You must be signed in to change notification settings - Fork 8
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
Add cooperative task manager #82
base: main
Are you sure you want to change the base?
Conversation
src/task_manager/cooperative.rs
Outdated
let tasks = [ | ||
Vec::new(), | ||
Vec::new(), | ||
Vec::new(), | ||
Vec::new(), | ||
Vec::new(), | ||
Vec::new(), | ||
Vec::new(), | ||
Vec::new(), | ||
Vec::new(), | ||
Vec::new(), | ||
Vec::new(), | ||
]; | ||
CooperativeTaskManager { | ||
tasks, | ||
next_task_id: 0, | ||
} |
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 can't we begin with empty tasks array?
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.
Each vector is for tasks of a specific priority and all possible priorities are initialized at the start of the manager.
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 can't we create vector for exact priority, when task with such priority appears? Cause seems like we use unnecessary memory. It may be critical for devices with small memory such as esp32.
Needs examples of new API usage |
Cooperative task manager representation based on round-robin scheduling with priorities.
CooperativeTask
is a shell forTask
(the general structure of the task for both cooperative and preemptive task manager) with fieldsid
,status
andpriority
.API:
new
--- create new task manager;add_task
--- create a task with default priority 0 and add it to the queue;add_priority_task
--- create a task with specified priority and add it to the queue;find_task
--- search and return for a task by its id;put_to_sleep
--- put the task to sleep by its id;terminate_task
--- put the task into the state of termination by its id. The task cannot be moved from this state to another one, it is deleted immediately using thedelete_task
function with private visibility;start_task_task_manager
--- starts task manager work;Status of the task changes during it execution. It possible statuses:
Ready
,Running
,Sleeping
,Terminated