dzavalishin / phantomuserland

Phantom: Persistent Operating System
GNU Lesser General Public License v3.0
893 stars 61 forks source link

fast unix v7 style spinlocks for persistent objects #602

Open dzavalishin opened 4 years ago

dzavalishin commented 4 years ago

pvm_sideway_lock( &pers_obj )

pvm_sideway_lock( void *addr )
{
    spinlock_t sl = get_hash( addr )
    spin_lock( sl )
}

or even better

sideway_spinlocks[N_SW_SL];

pvm_sideway_lock( void *addr )
{
    spinlock_t sl = sideway_spinlocks[ ((int)addr) % N_SW_SL];
    spin_lock( sl )
}

NB - conflict is ok, just two unrelated spinlocks will lock each other, which is not a real problem