diff --git a/src/sys/include/ubixos/sem.h b/src/sys/include/ubixos/sem.h new file mode 100644 index 0000000..bcf293b --- /dev/null +++ b/src/sys/include/ubixos/sem.h @@ -0,0 +1,39 @@ +/***************************************************************************************** + Copyright (c) 2002-2004 The UbixOS Project + All rights reserved. + + Redistribution and use in source and binary forms, with or without modification, are + permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this list of + conditions, the following disclaimer and the list of authors. Redistributions in binary + form must reproduce the above copyright notice, this list of conditions, the following + disclaimer and the list of authors in the documentation and/or other materials provided + with the distribution. Neither the name of the UbixOS Project nor the names of its + contributors may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id$ + +*****************************************************************************************/ + +#ifndef _SEM_H +#define _SEM_H + +#endif + +/*** + $Log$ + END + ***/ + diff --git a/src/sys/kernel/sched.c b/src/sys/kernel/sched.c index 0ed88a6..dd643b9 100644 --- a/src/sys/kernel/sched.c +++ b/src/sys/kernel/sched.c @@ -161,8 +161,12 @@ } /* else if (tmpTask->state == DEAD) { - schedDeleteTask(tmpTask->id); - goto schedStart; + if (tmpTask == _current) + kpanic("unhandled situation"); + //if (schedDeleteTask(tmpTask->id) != 0x0) { + // kpanic("Error: schedDeleteTask");; + // } + //goto schedStart; } */ } @@ -253,14 +257,16 @@ if (tmpTask->id == id) { if (_current == tmpTask) kpanic("you can not delete yourself!!!\n"); + if (tmpTask == taskList) + kpanic("Whoa"); tmpTask->prev->next = tmpTask->next; tmpTask->next->prev = tmpTask->prev; - break; + kfree(tmpTask->oInfo.cwd); + kfree(tmpTask); + return(0x0); } } - kfree(tmpTask->oInfo.cwd); - kfree(tmpTask); - return(0x0); + return(0x1); } @@ -330,6 +336,9 @@ /*** $Log$ + Revision 1.16 2004/07/20 18:51:00 reddawg + sched: hold that was my error + Revision 1.15 2004/07/19 02:32:21 reddawg sched: we now set task status to dead which then makes the scheduler do some clean it could be some minor overhead but i feel this is our most efficient approach right now to prevent corruption of the queues diff --git a/src/sys/kernel/sem.c b/src/sys/kernel/sem.c new file mode 100644 index 0000000..4d14043 --- /dev/null +++ b/src/sys/kernel/sem.c @@ -0,0 +1,35 @@ +/***************************************************************************************** + Copyright (c) 2002-2004 The UbixOS Project + All rights reserved. + + Redistribution and use in source and binary forms, with or without modification, are + permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this list of + conditions, the following disclaimer and the list of authors. Redistributions in binary + form must reproduce the above copyright notice, this list of conditions, the following + disclaimer and the list of authors in the documentation and/or other materials provided + with the distribution. Neither the name of the UbixOS Project nor the names of its + contributors may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id$ + +*****************************************************************************************/ + +#include + +/*** + $Log$ + END + ***/ diff --git a/src/sys/lib/kmalloc.c b/src/sys/lib/kmalloc.c index 69f14b7..92cc2ab 100644 --- a/src/sys/lib/kmalloc.c +++ b/src/sys/lib/kmalloc.c @@ -39,31 +39,22 @@ static struct memDescriptor *freeKernDesc = 0x0; static struct memDescriptor *emptyKernDesc = 0x0; -static spinLock_t mallocSpinLock = SPIN_LOCK_INITIALIZER; +static spinLock_t mallocSpinLock = SPIN_LOCK_INITIALIZER; +static spinLock_t emptyDescSpinLock = SPIN_LOCK_INITIALIZER; static void initMalloc() { int i = 0x0; - struct memDescriptor *tmpDesc1 = 0x0; - struct memDescriptor *tmpDesc2 = 0x0; emptyKernDesc = (struct memDescriptor *)vmmGetFreeKernelPage(sysID,4); - assert(emptyKernDesc); + memset(emptyKernDesc,0x0,0x4000); - tmpDesc1 = emptyKernDesc; - tmpDesc1->prev = 0x0; - tmpDesc1->status = 0x0; - tmpDesc1->limit = 0x0; + emptyKernDesc[0].next = &emptyKernDesc[1]; for (i = 0x1;i < ((0x1000/sizeof(struct memDescriptor))*4);i++) { - tmpDesc2 = &emptyKernDesc[i]; - tmpDesc2->prev = tmpDesc1; - tmpDesc1->next = tmpDesc2; - tmpDesc2->status = 0x0; - tmpDesc2->limit = 0x0; - tmpDesc1 = tmpDesc2; + emptyKernDesc[i].next = &emptyKernDesc[i+1]; + emptyKernDesc[i].prev = &emptyKernDesc[i-1]; } - tmpDesc1->next = 0x0; //Return return; } @@ -81,12 +72,15 @@ static void *getEmptyDesc() { struct memDescriptor *tmpDesc = emptyKernDesc; assert(tmpDesc); + + spinLock(&emptyDescSpinLock); if (tmpDesc != 0x0) { emptyKernDesc = tmpDesc->next; emptyKernDesc->prev = 0x0; tmpDesc->next = 0x0; tmpDesc->prev = 0x0; + spinUnlock(&emptyDescSpinLock); return(tmpDesc); } kpanic("Error Finding Empty Descriptor!\n"); @@ -341,6 +335,9 @@ /*** $Log$ + Revision 1.11 2004/07/18 05:24:15 reddawg + Fixens + Revision 1.10 2004/07/17 18:00:47 reddawg kmalloc: added assert()