Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

semaphore.h

Go to the documentation of this file.
00001 // See the end of this file for license information.
00002 
00003 #ifndef TORSION_SEMAPHORE_H
00004 #define TORSION_SEMAPHORE_H
00005 
00006 #include "list.h"
00007 class Semaphore;
00008 #include "task.h"
00009 
00013 
00014 class Semaphore {
00015 protected:
00016   List<Task> waiting_tasks;   
00017   unsigned value;     
00018 
00019 public:
00024   void
00025   init(unsigned start_value = 1);
00026 
00030   bool
00031   acquire(unsigned timeout = 0);
00032 
00035   bool
00036   try_acquire();
00037 
00040   bool
00041   release();
00042 
00044   void
00045   remove_task(Task* task);
00046 
00048   void
00049   print();
00050 
00051 };
00052 
00053 #endif
00054 
00055 /* Torsion Operating System, Copyright (C) 2000-2004 Dan Helfman
00056  *
00057  * This program is free software; you can redistribute it and/or modify it
00058  * under the terms of the GNU General Public License as published by the
00059  * Free Software Foundation; either version 2 of the License, or (at your
00060  * option) any later version.
00061  * 
00062  * This program is distributed in the hope that it will be useful, but
00063  * WITHOUT ANY WARRANTY; without even the implied warranty of
00064  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00065  * General Public License for more details (in the COPYING file).
00066  * 
00067  * You should have received a copy of the GNU General Public License along
00068  * with this program; if not, write to the Free Software Foundation, Inc.,
00069  * 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00070  */

Torsion Operating System, Copyright (C) 2000-2004 Dan Helfman