sys/src/mutex.c File Reference

mutexes More...

#include <system_data_cells.h>
#include <ipl.h>
#include <internals.h>
#include <pridef.h>
#include <wqhdef.h>
#include <linux/sched.h>
#include <ipldef.h>
#include <sch_routines.h>
#include <linux/spinlock.h>
#include <mtxdef.h>
#include <asm/bitops.h>
#include <statedef.h>
#include <queue.h>

Go to the source code of this file.

Defines

#define ioc_gq_mutex   ioc_spin

Functions

void mutexwait (struct _pcb *p, struct _mtx *m)
 stall process when waiting for mutex - see 5.2 8.5.3
void sch_lockw (struct _mtx *m)
 mutex for writing - see 5.2 8.5.2
void sch_lockr (struct _mtx *m)
 mutex for reading - see 5.2 8.5.1
void sch_iolockw (void)
void sch_unlock (struct _mtx *m)
 unlocking a mutex - see 5.2 8.5.4
void sch_unlockw (struct _mtx *m)
void sch_iounlockw (void)
void sch_iounlock (void)
void sch_std_ravail (int rsn)
 resource available
void sch_rwait (int rsn)


Detailed Description

mutexes

Author:
Roar Thronęs

Definition in file mutex.c.


Define Documentation

#define ioc_gq_mutex   ioc_spin

Definition at line 26 of file mutex.c.


Function Documentation

void mutexwait ( struct _pcb *  p,
struct _mtx m 
)

stall process when waiting for mutex - see 5.2 8.5.3

Parameters:
p pcb
m mutex

store mutex address in efwm

new pcb state MWAIT

insert into MWAIT scheduling queue

put on wait

Definition at line 37 of file mutex.c.

References sch_aq_wqhdr, and sch_waitl().

Referenced by sch_lockr(), sch_lockw(), and sch_rwait().

void sch_iolockw ( void   ) 

Definition at line 140 of file mutex.c.

References sch_lockw().

Referenced by exe_assign(), exe_crembx(), and exe_dassgn().

void sch_iounlock ( void   ) 

Definition at line 203 of file mutex.c.

References sch_unlockw().

Referenced by exe_assign(), and exe_dassgn().

void sch_iounlockw ( void   ) 

Definition at line 198 of file mutex.c.

References sch_unlockw().

Referenced by exe_crembx().

void sch_lockr ( struct _mtx m  ) 

mutex for reading - see 5.2 8.5.1

Parameters:
m mutex

spinlock sched

test mutex write flag

if set, stall process until available

if not set, grant readership

TODO check owncnt use here. copied from lockw?

own it is done by incrementing owncnt and mtxcnt

if it is the first to be locked

then record current priorities in pcb

TODO check if saved right with regard to realtime

if not realtime process, boost priority

release spinlock

Definition at line 100 of file mutex.c.

References _pcb, ctl_gl_pcb, IPL__ASTDEL, IPL__SCHED, _mtx::mtx_w_owncnt, mutexwait(), sch_change_cur_priority(), and SPIN_SCHED.

void sch_lockw ( struct _mtx m  ) 

mutex for writing - see 5.2 8.5.2

Parameters:
m mutex

spinlock sched

test and set mutex write flag

if set, no further readers or writers allowed, stall process

if no other owners

own it is done by incrementing owncnt and mtxcnt

if it is the first to be locked

then record current priorities in pcb

TODO check if saved right with regard to realtime

if not realtime process, boost priority

if other owners, stall

release spinlock

Definition at line 55 of file mutex.c.

References _pcb, ctl_gl_pcb, IPL__ASTDEL, IPL__SCHED, _mtx::mtx_w_owncnt, mutexwait(), sch_change_cur_priority(), and SPIN_SCHED.

Referenced by lnm_lock(), lnm_lockr(), lnm_lockw(), and sch_iolockw().

void sch_rwait ( int  rsn  ) 

Definition at line 228 of file mutex.c.

References ctl_gl_pcb, mutexwait(), and sch_gl_resmask.

void sch_std_ravail ( int  rsn  ) 

resource available

Definition at line 212 of file mutex.c.

References _pcb, IPL__MAILBOX, sch_chse(), sch_gl_resmask, sch_gq_mwait, SPIN_SCHED, _wqh::wqh_l_wqcnt, and _wqh::wqh_l_wqfl.

Referenced by bufpost(), and create_fork_thread().

void sch_unlock ( struct _mtx m  ) 

unlocking a mutex - see 5.2 8.5.4

Parameters:
m mutex

spinlock sched

decrement mtxcnt

if process does not own anymore, restore pris and change pri

TODO check if all saved are restore, and TODO check realtime

decrement owncnt

if no other owners

bbcci, test and clear write bit

if a writer had it

scan misc wait queue

search for those waiting for the now unlocked mutex

when found

decrease wqueue count

schedule that process

release spinlock

Definition at line 150 of file mutex.c.

References _pcb, ctl_gl_pcb, IPL__SCHED, _mtx::mtx_w_owncnt, sch_change_cur_priority(), sch_chse(), sch_gq_mwait, SPIN_SCHED, _wqh::wqh_l_wqcnt, and _wqh::wqh_l_wqfl.

Referenced by sch_unlockw().

void sch_unlockw ( struct _mtx m  ) 

Definition at line 194 of file mutex.c.

References sch_unlock().

Referenced by lnm_unlock(), lnm_unlockr(), lnm_unlockw(), sch_iounlock(), and sch_iounlockw().


Generated on Fri Oct 9 10:26:01 2009 for FreeVMS by  doxygen 1.5.5