diff --git a/src/sys/devfs/devfs.c b/src/sys/devfs/devfs.c index 491d128..5c04c8c 100644 --- a/src/sys/devfs/devfs.c +++ b/src/sys/devfs/devfs.c @@ -38,7 +38,7 @@ #include /* Spinlock for devfs we should start converting to sem/mutex */ -static spinLock_t devfsSpinLock = SPIN_LOCK_INITIALIZER; +static spinLock_t devfsSpinLock; /* Length of dev list */ static int devfs_len = 0x0; diff --git a/src/sys/include/ubixos/spinlock.h b/src/sys/include/ubixos/spinlock.h index 356bf28..5b6f7dc 100644 --- a/src/sys/include/ubixos/spinlock.h +++ b/src/sys/include/ubixos/spinlock.h @@ -1,40 +1,21 @@ -/***************************************************************************************** - 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 _SPINLOCK_H #define _SPINLOCK_H #include +#define SPIN_LOCK_INITIALIZER 0 -#define SPIN_LOCK_INITIALIZER 0 - -typedef volatile int spinLock_t; +typedef struct _spinLock spinLock_t; +struct _spinLock +{ + spinLock_t *First; + spinLock_t *Last; + spinLock_t *Next; + spinLock_t *Previous; + uInt8 *Locked; + uInt32 *ID; + uInt8 *Type; +}; void spinLockInit(spinLock_t *); void spinUnlock(spinLock_t *); @@ -49,6 +30,9 @@ /*** $Log$ + Revision 1.6 2004/09/11 13:01:05 apwillia + Make spinlock lock function sched_yield. Add spinlockLock_scheduler for use in smp-scheduler (avoids recursive call to sched). + Revision 1.5 2004/07/20 20:25:57 reddawg Works perfectly here diff --git a/src/sys/include/vmm/vmm.h b/src/sys/include/vmm/vmm.h index bd56c3d..232d338 100644 --- a/src/sys/include/vmm/vmm.h +++ b/src/sys/include/vmm/vmm.h @@ -52,7 +52,6 @@ mMap *Last; mMap *Next; mMap *Previous; - spinLock_t *lock; }; @@ -72,6 +71,9 @@ /*** $Log$ + Revision 1.13 2005/08/10 11:34:53 fsdfs + fixed a compiler error. + Revision 1.12 2005/08/10 09:47:41 fsdfs updates + kmalloc() and kfree() stubs diff --git a/src/sys/isa/fdc.c b/src/sys/isa/fdc.c index f49a15e..6d3f09b 100644 --- a/src/sys/isa/fdc.c +++ b/src/sys/isa/fdc.c @@ -41,7 +41,7 @@ #include #include -static spinLock_t fdcSpinLock = SPIN_LOCK_INITIALIZER; +static spinLock_t fdcSpinLock; static volatile bool done = FALSE; static drvGeom geometry = { dg144Heads,dg144Tracks,dg144Spt }; @@ -314,6 +314,9 @@ /*** $Log$ + Revision 1.24 2004/09/07 21:54:38 reddawg + ok reverted back to old scheduling for now.... + Revision 1.23 2004/09/06 15:13:25 reddawg Last commit before FreeBSD 6.0 diff --git a/src/sys/isa/ne2k.c b/src/sys/isa/ne2k.c index dafa49a..9ed4b64 100644 --- a/src/sys/isa/ne2k.c +++ b/src/sys/isa/ne2k.c @@ -41,7 +41,7 @@ #include -static spinLock_t ne2k_spinLock = SPIN_LOCK_INITIALIZER; +static spinLock_t ne2k_spinLock; static int dp_pkt2user(struct device *dev,int page,int length); static void getblock(struct device *dev,int page,size_t offset,size_t size,void *dst); @@ -341,7 +341,7 @@ struct nicBuffer *ne2kGetBuffer() { struct nicBuffer *tmpBuf = 0x0; - if (ne2k_spinLock == 0x1) + if (ne2k_spinLock.Locked == 0x1) return(0x0); tmpBuf = ne2kBuffer; @@ -359,6 +359,9 @@ /*** $Log$ + Revision 1.24 2004/09/28 21:47:56 reddawg + Fixed deadlock now safe to use in bochs + Revision 1.23 2004/09/16 22:35:28 reddawg Demo Release diff --git a/src/sys/kernel/sched.c b/src/sys/kernel/sched.c index d5ac232..b417355 100644 --- a/src/sys/kernel/sched.c +++ b/src/sys/kernel/sched.c @@ -51,7 +51,7 @@ kTask_t *_current = 0x0; kTask_t *_usedMath = 0x0; -static spinLock_t schedulerSpinLock = SPIN_LOCK_INITIALIZER; +static spinLock_t schedulerSpinLock; /************************************************************************ @@ -86,8 +86,7 @@ kTask_t *tmpTask = 0x0; kTask_t *delTask = 0x0; - if (!spinTryLock(&schedulerSpinLock)) - return; + spinLock(&schedulerSpinLock); tmpTask = _current->next; //outportByte(0xE9,_current->id + '0'); diff --git a/src/sys/kernel/spinlock.c b/src/sys/kernel/spinlock.c index 6d077dd..5e57483 100644 --- a/src/sys/kernel/spinlock.c +++ b/src/sys/kernel/spinlock.c @@ -1,56 +1,88 @@ -/***************************************************************************************** - 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 #include +spinLock_t *BigLock = NULL; +spinLock_t *BigLocksLock = NULL; + +#define READ 1 +#define WRITE 0 + +void spinWriteLock(spinLock_t *lock, uInt32 id, uInt8 emergency) +{ + spinLock_t *tmp; + spinLock(&BigLocksLock); + lock->Type = READ; + if(emergency) + { + tmp = BigLock->First->Next; + BigLock->First = lock; + tmp->Previous = lock; + } + else + { + tmp = BigLock->Last; + lock->Previous = tmp; + BigLock->Last = lock; + lock->Next = NULL; + } + spinUnlock(&BigLocksLock); + while(1) + { + spinLock(&BigLocksLock); + if(BigLock->First->ID != id && BigLock->First->Locked) + break; + spinUnlock(&BigLocksLock); + + } +} + +void spinReadLock(spinLock_t *lock, uInt32 id, uInt8 emergency) +{ + spinLock_t *tmp; + spinLock(&BigLocksLock); + lock->Type = READ; + if(emergency) + { + tmp = BigLock->First->Next; + BigLock->First = lock; + tmp->Previous = lock; + } + else + { + tmp = BigLock->Last; + lock->Previous = tmp; + BigLock->Last = lock; + lock->Next = NULL; + } + spinUnlock(&BigLocksLock); + while(1) + { + spinLock(&BigLocksLock); + if(BigLock->First->ID != id && BigLock->First->Locked) + break; + spinUnlock(&BigLocksLock); + + } +} + +/* void spinLockInit(spinLock_t *lock) { *lock = SPIN_LOCK_INITIALIZER; } - -void spinReadLock(spinLock_t *lock) -{ - *lock = 0x2; -} +*/ void spinLock(spinLock_t *lock) { - while (*lock != 0) - sched(); + while (lock->Locked != 0); } void spinUnlock(spinLock_t *lock) { - *lock = 0x0; + *lock->Locked = 0x0; } +/* int spinTryLock(spinLock_t *lock) { register int locked; @@ -71,7 +103,7 @@ { return(*lock != 0); } - +*/ /*** END diff --git a/src/sys/kernel/tty.c b/src/sys/kernel/tty.c index 39b79d0..97c7709 100644 --- a/src/sys/kernel/tty.c +++ b/src/sys/kernel/tty.c @@ -37,7 +37,7 @@ static tty_term *terms = 0x0; tty_term *tty_foreground = 0x0; -static spinLock_t tty_spinLock = SPIN_LOCK_INITIALIZER; +static spinLock_t tty_spinLock; int tty_init() { int i = 0x0; diff --git a/src/sys/lib/kmalloc.c b/src/sys/lib/kmalloc.c index 641d33f..88245c5 100644 --- a/src/sys/lib/kmalloc.c +++ b/src/sys/lib/kmalloc.c @@ -51,8 +51,8 @@ /* Set up our spinlocks so we do not corrupt linked lists if we have re-entrancy */ -static spinLock_t mallocSpinLock = SPIN_LOCK_INITIALIZER; -static spinLock_t emptyDescSpinLock = SPIN_LOCK_INITIALIZER; +static spinLock_t mallocSpinLock; +static spinLock_t emptyDescSpinLock; /************************************************************************ @@ -394,6 +394,9 @@ /*** $Log$ + Revision 1.36 2005/08/08 21:33:44 fsdfs + new scheduler! + Revision 1.35 2005/08/04 18:32:59 fsdfs added error reporting diff --git a/src/sys/mpi/system.c b/src/sys/mpi/system.c index 5b734e5..38eaa7c 100644 --- a/src/sys/mpi/system.c +++ b/src/sys/mpi/system.c @@ -33,7 +33,7 @@ #include static mpi_mbox_t *mboxList = 0x0; -static spinLock_t mpiSpinLock = SPIN_LOCK_INITIALIZER; +static spinLock_t mpiSpinLock; /***************************************************************************************** diff --git a/src/sys/net/net/sys_arch.c b/src/sys/net/net/sys_arch.c index 38d43bb..7735efb 100644 --- a/src/sys/net/net/sys_arch.c +++ b/src/sys/net/net/sys_arch.c @@ -35,6 +35,9 @@ * Modified to work with the ubix operating system * * $Log$ + * Revision 1.6 2004/09/11 21:30:37 apwillia + * Fix race conditions in net thread and scheduler + * * Revision 1.5 2004/09/07 20:58:35 reddawg * time to roll back i can't think straight by friday * @@ -84,7 +87,8 @@ #define UMAX(a, b) ((a) > (b) ? (a) : (b)) static struct sys_thread *threads = 0x0; -static spinLock_t netThreadSpinlock = SPIN_LOCK_INITIALIZER; +static spinLock_t netThreadSpinlock; + struct sys_mbox_msg { struct sys_mbox_msg *next; diff --git a/src/sys/sys/device.c b/src/sys/sys/device.c index af4ac8c..e9f7546 100644 --- a/src/sys/sys/device.c +++ b/src/sys/sys/device.c @@ -34,7 +34,7 @@ /* Linked list of drivers loaded in the system accessable by the subsystem only */ static struct device_node *devices = 0x0; -static spinLock_t deviceSpinLock = SPIN_LOCK_INITIALIZER; +static spinLock_t deviceSpinLock; /***************************************************************************************** @@ -86,7 +86,7 @@ struct device_node *tmpDev = 0x0; spinLock(&deviceSpinLock); - spinLock_scheduler(&deviceSpinLock); +// spinLock_scheduler(&deviceSpinLock); for (tmpDev = devices;tmpDev;tmpDev=tmpDev->next) { if ((tmpDev->devInfo->major == major) && (tmpDev->minor == minor)) { diff --git a/src/sys/ubixfs/dirCache.c b/src/sys/ubixfs/dirCache.c index a40b245..d725914 100644 --- a/src/sys/ubixfs/dirCache.c +++ b/src/sys/ubixfs/dirCache.c @@ -36,7 +36,7 @@ #include -static spinLock_t dca_spinLock = SPIN_LOCK_INITIALIZER; +static spinLock_t dca_spinLock; static struct directoryEntry * @@ -260,6 +260,9 @@ /*** $Log$ + Revision 1.30 2004/08/14 11:23:02 reddawg + Changes + Revision 1.29 2004/08/09 12:58:05 reddawg let me know when you got the surce @@ -332,6 +335,9 @@ Revision 1.5 2004/07/20 19:21:30 reddawg You like leaving out $Log$ + You like leaving out Revision 1.30 2004/08/14 11:23:02 reddawg + You like leaving out Changes + You like leaving out You like leaving out Revision 1.29 2004/08/09 12:58:05 reddawg You like leaving out let me know when you got the surce You like leaving out diff --git a/src/sys/vfs/file.c b/src/sys/vfs/file.c index 2c70ea3..38b1b1b 100644 --- a/src/sys/vfs/file.c +++ b/src/sys/vfs/file.c @@ -40,7 +40,7 @@ #include #include -static spinLock_t fdTable_lock = SPIN_LOCK_INITIALIZER; +static spinLock_t fdTable_lock; fileDescriptor *fdTable = 0x0; diff --git a/src/sys/vmm/copyvirtualspace.c b/src/sys/vmm/copyvirtualspace.c index 5b806f9..0e48f4d 100644 --- a/src/sys/vmm/copyvirtualspace.c +++ b/src/sys/vmm/copyvirtualspace.c @@ -34,7 +34,7 @@ #include #include #include -static spinLock_t cvsSpinLock = SPIN_LOCK_INITIALIZER; +static spinLock_t cvsSpinLock; /************************************************************************ @@ -205,6 +205,9 @@ /*** $Log$ + Revision 1.11 2005/08/10 09:47:41 fsdfs + updates + kmalloc() and kfree() stubs + Revision 1.10 2005/08/10 06:01:59 fsdfs cleaned up dependencies. rewrote vmmCopyVirtualSpace. does not compile CVSn: ---------------------------------------------------------------------- diff --git a/src/sys/vmm/getfreepage.c b/src/sys/vmm/getfreepage.c index db90972..cb6b0b0 100644 --- a/src/sys/vmm/getfreepage.c +++ b/src/sys/vmm/getfreepage.c @@ -31,7 +31,7 @@ #include #include #include -static spinLock_t vmmGFPlock = SPIN_LOCK_INITIALIZER; +static spinLock_t vmmGFPlock; /************************************************************************ @@ -79,6 +79,9 @@ /*** $Log$ + Revision 1.13 2005/08/10 09:47:41 fsdfs + updates + kmalloc() and kfree() stubs + Revision 1.12 2005/08/10 06:01:59 fsdfs cleaned up dependencies. rewrote vmmCopyVirtualSpace. does not compile CVSn: ---------------------------------------------------------------------- diff --git a/src/sys/vmm/getfreevirtualpage.c b/src/sys/vmm/getfreevirtualpage.c index f65f05f..11cc5cf 100644 --- a/src/sys/vmm/getfreevirtualpage.c +++ b/src/sys/vmm/getfreevirtualpage.c @@ -32,7 +32,7 @@ #include #include -static spinLock_t fvpSpinLock = SPIN_LOCK_INITIALIZER; +static spinLock_t fvpSpinLock; /************************************************************************ @@ -124,6 +124,9 @@ /*** $Log$ + Revision 1.6 2005/08/09 08:45:40 fsdfs + reverting to old vmm. i may have modified something accidently when i wasted time indenting the code. + Revision 1.4 2004/07/28 15:05:43 reddawg Major: Pages now have strict security enforcement. diff --git a/src/sys/vmm/memory.c b/src/sys/vmm/memory.c index 092cc1c..3f83008 100644 --- a/src/sys/vmm/memory.c +++ b/src/sys/vmm/memory.c @@ -36,8 +36,8 @@ #include #include -static spinLock_t vmmSpinLock = SPIN_LOCK_INITIALIZER; -static spinLock_t vmmCowSpinLock = SPIN_LOCK_INITIALIZER; +static spinLock_t vmmSpinLock; +static spinLock_t vmmCowSpinLock; uInt32 usedPages; uInt32 freePages; @@ -340,6 +340,9 @@ /*** $Log$ + Revision 1.21 2005/08/10 09:47:41 fsdfs + updates + kmalloc() and kfree() stubs + Revision 1.20 2005/08/10 06:01:59 fsdfs cleaned up dependencies. rewrote vmmCopyVirtualSpace. does not compile CVSn: ---------------------------------------------------------------------- diff --git a/src/sys/vmm/pagefault.c b/src/sys/vmm/pagefault.c index 18f2dc1..fd6c6db 100644 --- a/src/sys/vmm/pagefault.c +++ b/src/sys/vmm/pagefault.c @@ -34,7 +34,7 @@ #include #include #include -static spinLock_t pageFaultSpinLock = SPIN_LOCK_INITIALIZER; +static spinLock_t pageFaultSpinLock; /***************************************************************************************** @@ -152,6 +152,9 @@ /*** $Log$ + Revision 1.20 2005/08/10 07:07:03 fsdfs + vmm_pageFault2() implemented + Revision 1.19 2005/08/10 06:01:59 fsdfs cleaned up dependencies. rewrote vmmCopyVirtualSpace. does not compile CVSn: ---------------------------------------------------------------------- diff --git a/src/sys/vmm/paging.c b/src/sys/vmm/paging.c index ddfa336..4e4ea68 100644 --- a/src/sys/vmm/paging.c +++ b/src/sys/vmm/paging.c @@ -40,8 +40,8 @@ uInt32 *kernelPageDirectory = 0x0; -static spinLock_t fkpSpinLock = SPIN_LOCK_INITIALIZER; -static spinLock_t rmpSpinLock = SPIN_LOCK_INITIALIZER; +static spinLock_t fkpSpinLock; +static spinLock_t rmpSpinLock; /***************************************************************************************** @@ -425,6 +425,9 @@ /*** $Log$ + Revision 1.20 2005/08/09 08:45:40 fsdfs + reverting to old vmm. i may have modified something accidently when i wasted time indenting the code. + Revision 1.18 2004/09/07 21:54:38 reddawg ok reverted back to old scheduling for now....