00001 /*-------------------------------------------------------------------- 00002 * 00003 * (C) Copyright Koninklijke Philips Electronics NV 2006. 00004 * All rights reserved. This software is licensed under the terms of 00005 * version 2.1 of the GNU Lesser General Public License as published 00006 * by the Free Software Foundation. For licensing and warranty 00007 * information, see the file COPYING in the main directory. 00008 * 00009 *------------------------------------------------------------------*/ 00010 00011 #include "trtos.h" 00012 #include "trttask.h" 00013 #include "trtmutex.h" 00014 #include "trtsemaphore.h" 00015 #include "trt.h" 00016 #include "os.h" 00017 #include <stdio.h> 00018 #include <algorithm> 00019 00020 static Os* os = 0; 00021 00022 static void trt_trap() 00023 { 00024 if (os) { 00025 os->deadlockHandler(); 00026 } else { 00027 printf("TRT deadlock ... exiting\n"); 00028 exit(1); 00029 } 00030 } 00031 00032 trtOs::trtOs() : 00033 Os() 00034 { 00035 os = this; 00036 trt_init(NULL, NULL); //only on Linux 00037 trt_onidle(trt_trap); 00038 } 00039 00040 trtOs::~trtOs() 00041 { } 00042 00043 osTask* trtOs::createTask(void (*f)(void*), void* a) 00044 { 00045 return new trtTask(f,a); 00046 } 00047 00048 osMutex* trtOs::createMutex(bool locked) 00049 { 00050 return new trtMutex(locked); 00051 } 00052 00053 osSemaphore* trtOs::createSemaphore(int credit) 00054 { 00055 return new trtSemaphore(credit); 00056 } 00057 00058 Os* boot() 00059 { 00060 return new trtOs(); 00061 }