|
|
DataMuseum.dkPresents historical artifacts from the history of: RC9000 |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about RC9000 Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - downloadIndex: @ T t
Length: 6113 (0x17e1)
Types: TextFile
Notes: @(#)txqueue.h 13.2 (RC International) 91/02/05 */
Names: »txqueue.h«
└─⟦50656ff4a⟧ Bits:30010538 TX 3.1 Coldstart
└─⟦bbf173f5c⟧ »0004«
└─⟦this⟧ »./usr/include/sys/txqueue.h«
/* @(#)txqueue.h 13.2 (RC International) 91/02/05 */
/*
* txqueue.h -- defines the semaphore and txqueue structures
*
* These structures are used with the procedures of sys/kern_txqueue.c
* to implement multi-processor semaphores and queues in TX.
*/
#ifndef _TXQUEUE_
#define _TXQUEUE_
/*
* prc -- both TX and RTE process structures must begin like this:
*/
struct prc
{
struct prc *p_unixlink; /* unix forward link */
struct prc *p_unixbacklink;/* unix back link */
char p_processor; /* which processor owns this process */
char rte1; /* used by RTE */
short rte2; /* used by RTE */
struct prc *p_link; /* txqueue link */
struct txqueue *p_q; /* [TX only] txqueue on which we are waiting */
};
/*
* p_processor bit definitions:
*/
#define P_NULL 0 /* process is alive */
#define UPU_SLEEP (1 << 0) /* process is asleep on the UPU */
#define RPU_SLEEP (1 << 1) /* process is asleep on the RPU */
#define SIG_AWAKE (1 << 2) /* process being awakened by SIGNAL */
#define TIME_AWAKE (1 << 3) /* process being awakened by timer */
#define NORMAL_AWAKE (1 << 4) /* process being awakened normally */
#define P_PROC (UPU_SLEEP | RPU_SLEEP)
#define P_AWAKE (SIG_AWAKE | TIME_AWAKE | NORMAL_AWAKE)
#define P_TRASH (0xffffffff ^ (P_PROC | P_AWAKE))
/*
* semaphore -- a place for a list of processes to wait
*/
struct semaphore
{
unsigned volatile char sem_rcount; /* number of RPU processes waiting */
/* or holding semaphore */
unsigned volatile char sem_ucount; /* number of UPU processes waiting */
/* or holding semaphore */
unsigned volatile char sem_uwait; /* UPU process is waiting */
unsigned volatile char sem_rwait; /* UPU process is waiting */
volatile struct prc *sem_owner; /* current holder of the lock */
volatile struct prc *sem_unext; /* oldest waiting UPU processes */
volatile struct prc *sem_ulast; /* youngest waiting UPU processes */
volatile struct prc *sem_rnext; /* oldest waiting RPU processes */
volatile struct prc *sem_rlast; /* youngest waiting RPU processes */
struct sem_stat *sem_stats; /* statistics block */
};
/*
* some fields/values which are different between the UPU and RPU
*/
#if RPU
#define sem_mycount sem_rcount
#define sem_hiscount sem_ucount
#define sem_mynext sem_rnext
#define sem_hisnext sem_unext
#define sem_mylast sem_rlast
#define sem_hislast sem_ulast
#define sem_mywait sem_rwait
#define sem_hiswait sem_uwait
#define sems_waits sems_rwaits
#define sems_wblock sems_rwblock
#define sems_spins sems_rspins
#else !RPU
#define sem_mycount sem_ucount
#define sem_hiscount sem_rcount
#define sem_mynext sem_unext
#define sem_hisnext sem_rnext
#define sem_mylast sem_ulast
#define sem_hislast sem_rlast
#define sem_mywait sem_uwait
#define sem_hiswait sem_rwait
#define sems_waits sems_uwaits
#define sems_wblock sems_uwblock
#define sems_spins sems_uspins
#endif !RPU
/*
* rwlock -- a read/write lock
*/
#define READLOCK 1
#define WRITELOCK 2
#define LOCK_MASK 3
#define IS_LOCKED 4
#define LEAVE_LOCKED 8
struct rwlock
{
short rw_rcount; /* reader count */
short rw_wcount; /* writer count (1 or 0) */
short rw_wrcount; /* waiting reader count */
short rw_wwcount; /* waiting writer count */
struct prc *rw_owner; /* write lock owner */
struct prc *rw_rnext; /* oldest waiting reader process */
struct prc *rw_rlast; /* youngest waiting reader process */
struct prc *rw_wnext; /* oldest waiting writer process */
struct prc *rw_wlast; /* youngest waiting writer process */
};
/*
* txqueue -- a place to queue messages and/or processes waiting for them
*/
struct txqueue
{
volatile short q_pcount; /* # of procs waiting for a message */
volatile short q_mcount; /* # of messages currently queued */
volatile struct prc *q_pnext; /* oldest in waiting processes list */
volatile struct prc *q_plast; /* youngest in waiting processes list */
volatile struct msg *q_mhead; /* head of message list */
volatile struct msg *q_mtail; /* tail of message list */
int q_cause; /* event cause */
struct txq_stat *q_stats; /* statistics block */
};
/*
* event macros
*/
#define e_set(q, cause) ((q)->q_cause = cause)
#define e_clear(q) ((q)->q_cause = 0)
#define e_caused(q) ((q)->q_cause)
/*
* wakeup_list -- used to queue processes for the other processor to awaken
*/
#define WL_SIZE 32
struct wakeup_list
{
unsigned volatile short wl_in; /* input index into wl_list */
unsigned volatile short wl_out; /* output index into wl_list */
unsigned volatile short wl_max; /* max number of entries queued */
unsigned volatile short wl_spins; /* number of overflow spins */
volatile struct prc *wl_list[WL_SIZE];/* list of processes to awaken */
};
/*
* some macros for manipulation of wakeup_list(s)
*/
#define WL_COUNT(wl) (((wl)->wl_in - (wl)->wl_out) & (WL_SIZE - 1))
#define EMPTY_WL(wl) ((wl)->wl_in == (wl)->wl_out)
#define REMOVE_WL(wl) ((wl)->wl_list[(wl)->wl_out++ & (WL_SIZE - 1)])
#define ADD_WL(p, wl) \
{ \
if ( WL_COUNT(wl) >= (wl)->wl_max ) \
new_wl_max(wl); \
(wl)->wl_list[(wl)->wl_in & (WL_SIZE - 1)] = p; \
(wl)->wl_in++; \
wbflush(); \
zap; /* interrupt the other processor */ \
}
/*
* Global info used by kern_queue module on both processors - pointed to by
* tx_info.
*/
struct txqueue_info
{
spin_t txqueue_lock; /* for all of kern_txqueue module */
struct wakeup_list upu_hole; /* wakeup_list for UPU processes */
struct wakeup_list rpu_hole; /* wakeup_list for RPU processes */
struct txq_stat *txqstathead; /* head of txq_stat block list */
struct sem_stat *semstathead; /* head of sem_stat block list */
};
/*
* qr_ret_t -- return values of queue_remove and e_wait
*/
typedef enum
{
QR_OK, /* gave back a message */
QR_WOULD_BLOCK, /* would have blocked */
QR_SIGNALED, /* a signal occurred */
QR_TIMEDOUT, /* time expired */
QR_CAUSED /* woken by an event */
} qr_ret_t;
#endif _TXQUEUE_