spinlock.c
ubixos/spinlock.h
ubixos/sched.h
sys/thread.h
ubixos/sched.h
ubixos/spinlock.h
ubixos/types.h
sys/_types.h
vfs/file.h
sys/tss.h
vfs/mount.h
ubixfs/dirCache.h
src/sys/kernel/spinlock.c
ubixos/tty.h
void void spinLock (spinLock_t *lock) spinLock spinLock_t * lock sched_yield spinTryLock adjustCowCounter cpuInfo devfs_makeNode devfs_open device_add device_find device_remove fclose fdcRead fopen freePage getEmptyDesc kernel_function kfree kmalloc mpi_createMbox mpi_destroyMbox mpi_fetchMessage mpi_postMessage mpi_spam ne2kAllocBuffer schedNewTask smpInit tty_print ubixfs_cacheAdd ubixfs_cacheFind vmm_getFreeMallocPage vmm_pageFault vmm_remapPage vmmCopyVirtualSpace vmmFindFreePage vmmFreeProcessPages vmmGetFreeKernelPage vmmGetFreePage vmmGetFreeVirtualPage
void void spinLock_scheduler (spinLock_t *lock) spinLock_scheduler spinLock_t * lock spinTryLock
void void spinLockInit (spinLock_t *lock) spinLockInit spinLock_t * lock SPIN_LOCK_INITIALIZER
int int spinLockLocked (spinLock_t *lock) spinLockLocked spinLock_t * lock c_ap_boot
int int spinTryLock (spinLock_t *lock) spinTryLock spinLock_t * lock keyboardHandler sched spinLock spinLock_scheduler
void void spinUnlock (spinLock_t *lock) spinUnlock spinLock_t * lock adjustCowCounter cpuInfo devfs_makeNode devfs_open device_add device_find device_remove fclose fdcRead fopen freePage getEmptyDesc kernel_function keyboardHandler kfree kmalloc mpi_createMbox mpi_destroyMbox mpi_fetchMessage mpi_postMessage mpi_spam ne2kAllocBuffer schedNewTask smpInit tty_print ubixfs_cacheAdd ubixfs_cacheFind vmm_getFreeMallocPage vmm_pageFault vmm_remapPage vmmCopyVirtualSpace vmmFindFreePage vmmFreeProcessPages vmmGetFreeKernelPage vmmGetFreePage vmmGetFreeVirtualPage

    /*****************************************************************************************
    Copyright(c)2002-2004TheUbixOSProject
    Allrightsreserved.

    Redistributionanduseinsourceandbinaryforms,withorwithoutmodification,are
    permittedprovidedthatthefollowingconditionsaremet:

    Redistributionsofsourcecodemustretaintheabovecopyrightnotice,thislistof
    conditions,thefollowingdisclaimerandthelistofauthors.Redistributionsinbinary
    formmustreproducetheabovecopyrightnotice,thislistofconditions,thefollowing
    disclaimerandthelistofauthorsinthedocumentationand/orothermaterialsprovided
    withthedistribution.NeitherthenameoftheUbixOSProjectnorthenamesofits
    contributorsmaybeusedtoendorseorpromoteproductsderivedfromthissoftware
    withoutspecificpriorwrittenpermission.

    THISSOFTWAREISPROVIDEDBYTHECOPYRIGHTHOLDERSANDCONTRIBUTORS"ASIS"ANDANY
    EXPRESSORIMPLIEDWARRANTIES,INCLUDING,BUTNOTLIMITEDTO,THEIMPLIEDWARRANTIESOF
    MERCHANTABILITYANDFITNESSFORAPARTICULARPURPOSEAREDISCLAIMED.INNOEVENTSHALL
    THECOPYRIGHTOWNERORCONTRIBUTORSBELIABLEFORANYDIRECT,INDIRECT,INCIDENTAL,
    SPECIAL,EXEMPLARY,ORCONSEQUENTIALDAMAGES(INCLUDING,BUTNOTLIMITEDTO,PROCUREMENT
    OFSUBSTITUTEGOODSORSERVICES;LOSSOFUSE,DATA,ORPROFITS;ORBUSINESSINTERRUPTION)
    HOWEVERCAUSEDANDONANYTHEORYOFLIABILITY,WHETHERINCONTRACT,STRICTLIABILITY,OR
    TORT(INCLUDINGNEGLIGENCEOROTHERWISE)ARISINGINANYWAYOUTOFTHEUSEOFTHIS
    SOFTWARE,EVENIFADVISEDOFTHEPOSSIBILITYOFSUCHDAMAGE.

    $Id: spinlock_8c.xml 88 2016-01-12 00:11:29Z reddawg $

    *****************************************************************************************/

    #include<ubixos/spinlock.h>
    #include<ubixos/sched.h>

    voidspinLockInit(spinLock_t*lock){
    *lock=SPIN_LOCK_INITIALIZER;
    }

    voidspinUnlock(spinLock_t*lock){
    *lock=0x0;
    /*
    registerintunlocked;
    asmvolatile(
    "xchgl%0,%1"
    :"=&r"(unlocked),"=m"(*lock):"0"(0)
    );
    */
    }

    intspinTryLock(spinLock_t*lock){
    registerintlocked;
    asmvolatile("xchgl%0,%1"
    :"=&r"(locked),"=m"(*lock):"0"(1)
    );
    return(!locked);
    }

    voidspinLock(spinLock_t*lock){
    while(!spinTryLock(lock))
    {
    while(*lock==1)
    sched_yield();
    }
    }

    voidspinLock_scheduler(spinLock_t*lock){
    while(!spinTryLock(lock))
    while(*lock==1);
    }

    intspinLockLocked(spinLock_t*lock){
    return(*lock!=0);
    }

    /***
    END
    ***/