Fix semop return type. Do some minor style-based fixes.

This commit is contained in:
Enrico Fraccaroli (Galfurian)
2023-06-02 13:49:10 -04:00
parent 116f4a50f7
commit 8891ed7d7a
14 changed files with 73 additions and 69 deletions
+12 -11
View File
@@ -95,6 +95,7 @@ task_struct *scheduler_get_running_process(pid_t pid)
void scheduler_enqueue_task(task_struct *process)
{
assert(process && "Received a NULL process.");
// If current_process is NULL, then process is the current process.
if (runqueue.curr == NULL) {
runqueue.curr = process;
@@ -109,6 +110,7 @@ void scheduler_enqueue_task(task_struct *process)
void scheduler_dequeue_task(task_struct *process)
{
assert(process && "Received a NULL process.");
scheduler_feedback_task_remove(process->pid);
// Delete the process from the list of running processes.
list_head_remove(&process->run_list);
@@ -208,7 +210,7 @@ void scheduler_enter_user_jmp(uintptr_t location, uintptr_t stack)
/// @param mode The type of wait (TASK_INTERRUPTIBLE or TASK_UNINTERRUPTIBLE).
/// @param sync Specifies if the wakeup should be synchronous.
/// @return 1 on success, 0 on failure.
static inline int try_to_wake_up(task_struct *process, int mode, int sync)
static inline int try_to_wake_up(task_struct *process, unsigned mode, int sync)
{
// Only tasks in the state TASK_UNINTERRUPTIBLE can be woke up
if (process->state == TASK_UNINTERRUPTIBLE || process->state == TASK_STOPPED) {
@@ -229,27 +231,26 @@ wait_queue_entry_t *sleep_on(wait_queue_head_t *wq)
{
// Save the sleeping process registers state
task_struct *sleeping_task = scheduler_get_current_process();
// Stops task from runqueue making it unrunnable.
sleeping_task->state = TASK_UNINTERRUPTIBLE;
#if 0
pt_regs* f = get_current_interrupt_stack_frame();
// Get the interrupt registers.
pt_regs *f = get_current_interrupt_stack_frame();
// Store its context.
scheduler_store_context(f, sleeping_task);
// Select next process in the runqueue as the current, restore it's context,
// we assume that the first process is init wich does not sleep (I hope).
// This is necessary to make the scheduler_run() in syscall_handler work.
task_struct *next = list_entry(runqueue.queue.next, task_struct, run_list);
task_struct *next = scheduler_pick_next_task(&runqueue);
assert((next != sleeping_task) && "The next selected process in the runqueue is the sleeping process");
scheduler_restore_context(next, f);
#endif
// Stops task from runqueue making it unrunnable
sleeping_task->state = TASK_UNINTERRUPTIBLE;
// Add sleeping process to sleep wait queue
// Allocate the wait_queue entry.
wait_queue_entry_t *wait_entry = kmalloc(sizeof(struct wait_queue_entry_t));
// Initialize the entry.
init_waitqueue_entry(wait_entry, sleeping_task);
// Add sleeping process to sleep wait queue.
add_wait_queue(wq, wait_entry);
return wait_entry;
}