/**
 * @file sched.h
 * @brief Header file for implementation of simple scheduler, file sched.h
 * 
 * Scheduler is implemented as simple round robin (no priorities).
 * Scheduler holds all the time two queues of threads. One for runnable threads (unsorted fifo)
 * and one for to_remove_zombie threads (), that 
 * are finished, somebody join them or they were detached and can be removed from system. Threse
 * zombie threads are removed from system in function schedule(). Sleeping threads dont need
 * any special queue, all the thread has internal timer, and rutine called from this timer
 * wake up thread to be set as runnable. running thread is on the head of runnable threads in
 * the time of execution code of it.
 * Scheduler at first try to wake up sleeping threads (, check timers,so move them in queue 
 * of ready to run threads),
 * Than remove zombies, that could be removed (thread can not free memory of itself), and
 * than switch context for the first ready to run thread.
 * In system is all the time at least one runnable thread, system thread with ID == 0.
 * 
 * This file is based on Kalisto, Development Kernel copyrighted (c) to 
 * Distributed Systems Research Group MFF UK, Czech republic.
 */
#ifndef _SCHED_H_
#define _SCHED_H_

#include "thread.h"
#include "tqueue.h"

void init_scheduler (); 
void runnable (struct thread_struct *t);
void disabled (struct thread_struct *t);

void context_switch (struct thread_struct *t);
void schedule (void);

extern thread_queue_t runnable_threads;
extern thread_queue_t sleeping_threads;
extern thread_queue_t zombies_to_kill_threads;
extern thread_queue_t valid_threads;

#endif /* _SCHED_H_ */
