Main Page | Directories | File List | Globals

wait.c

Go to the documentation of this file.
00001 /*
00002  * kernel_super/sched/wait.c
00003  *
00004  * Copyright (c) 2003-2004 Lukasz Dembinski <dembol@nasa.com.pl>
00005  * All Rights Reserved
00006  * 
00007  * Date:        2004/01
00008  * Author:      Lukasz Dembinski
00009  * Info:        wait.c core file
00010  * Contact:     mailto: <dembol@nasa.com.pl>
00011  *
00012  */
00013 
00014 #include <agnix/agnix.h>
00015 #include <agnix/list.h>
00016 #include <agnix/tasks.h> 
00017 #include <agnix/sched.h> 
00018 #include <agnix/spinlock.h>
00019 #include <agnix/wait.h>
00020 
00021 void wait_list_add(struct task_s *task, struct wait_list_s *waitlist)
00022 {
00023     u32 flags;
00024 
00025     spin_lock_irqsave(&(waitlist->lock), flags);
00026     list_add(&(task->wait_list), &(waitlist->list));
00027     spin_unlock_irqrestore(&(waitlist->lock), flags);
00028 }
00029 
00030 void wait_list_del(struct task_s *task, struct wait_list_s *waitlist)
00031 {
00032     u32 flags;
00033 
00034     spin_lock_irqsave(&(waitlist->lock), flags);
00035     list_del(&(task->wait_list));
00036     spin_unlock_irqrestore(&(waitlist->lock), flags);
00037 }
00038 
00039 void wait_list_sleep_on(struct task_s *task, struct wait_list_s *waitlist)
00040 {
00041     wait_list_add(task, waitlist);    
00042     sched_deactivate_task(task);
00043     schedule_task();
00044 }
00045 
00046 void wait_list_remove(struct task_s *task, struct wait_list_s *waitlist)
00047 {
00048     wait_list_del(task, waitlist);    
00049 }
00050 
00051 void wait_list_wake_up(struct wait_list_s *waitlist)
00052 {
00053     struct list_head *tmp;
00054     struct task_s *task;
00055     u32 flags;
00056 
00057     spin_lock_irqsave(&waitlist->lock, flags);
00058     
00059     if (list_empty(&waitlist->list)) {
00060         spin_unlock_irqrestore(&waitlist->lock, flags);
00061         return;
00062     }
00063 
00064     list_for_each(tmp, &waitlist->list) {
00065         task = list_entry(tmp, struct task_s, wait_list);
00066         sched_activate_task(task);
00067     }
00068     
00069     INIT_LIST_HEAD(&waitlist->list);
00070     
00071     spin_unlock_irqrestore(&waitlist->lock, flags);
00072 }
00073 
00074 void wait_list_init(struct wait_list_s *waitlist)
00075 {
00076     INIT_LIST_HEAD(&waitlist->list);
00077     spin_lock_init(&waitlist->lock);
00078 }
Dokumentacje wygenerowano programem Doxygen 1.4.2 dla projektu Agnix