[FreeVMS] (no subject)

Roger Tucker roger.tucker at mci.com
Mer 13 Juil 20:03:19 CEST 2005


I rarely have time to look at freevms (much less work on it), although I
would love to see it be successful.

When I do, I feel somewhat overwhelmed as to even where to begin, so I
congratulate those who are trying.

 

I had time this morning and just grabbed a routine to see how things were
going.

I choose sch$qast() because I love VMS asts.

 

I think I noticed a few problems in synchronization in the code and wanted
to talk about that - more as an education example than any sort of
complaining.  (I have no room to complain, since I haven't done much to help
out.)

 

In the freevms version of sch$qast() the code is as follows:

 

struct _pcb * p = exe$ipid_to_pcb(pid);

if (!p) return SS$_NONEXPR;

saveipl = getipl();

spin_lock(&SPIN_SCHED);

setipl(IPL$SYNCH);

insque(a, &p->pcb$l_astqfl);

.

 

The problems I see with synchronization in the code are:

 

1.	SCHED IPL and SPIN_LOCK must be acquired before getting the pcb.  If
a pointer to the pcb is obtained without getting the SCHED synchronization,
then the PCB pointer could become invalid or change before use.
2.	I believe IPL must be raised before taking out the spin_lock.

If the spin_lock is acquired without IPL being raised, an interrupt could
interrupt and try to get the same spinlock and deadlock.

The rule for openvms is to always raise IPL to block the current CPU and
then get the spinlock to block the other CPUs.

(Getting the spinlock is even optional when running on a single CPU.)

      3.   insque doesn't have to be atomic since we hold the SCHED
spinlock.

 

I believe the basic code should go something like this.

 

            setipl(SYNCH);

            spin_lock(SCHED);

            struct _pcb *p = exe$ipid_to_pcb(pid);

            insque_el(a, &p->pcb$l_astqfl);

 

There are many other things to worry about (like reordering of
instructions), but I wanted to point this out.

 

Roger Tucker

 

 

-------------- section suivante --------------
Une pièce jointe HTML a été nettoyée...
URL: http://www.systella.fr/pipermail/freevms/attachments/20050713/436636c9/attachment.htm 


Plus d'informations sur la liste de diffusion FreeVMS