Problems with hardware lock allocation

Buckaroo Banzai mike at SNOWHITE.CIS.UOGUELPH.CA
Wed Aug 1 16:09:31 AEST 1990


    Hi.  I am having hassles with locks on a 4D-240 (under IRIX 3.2.1).
The online manual states that I can allocate 4096 hardware locks from each
arena that I have created, and if I ensure that the creator of the arena
allocates the locks (via 'usnewlock', of course), then many locks may be had 
with no trouble.

    Trouble starts when I 'sproc' some kids and have _them_ allocate some
locks from the same arena.  Sometimes the locks are allocated pre-set (which
is an inconvenience), and sometimes the child silently dies inside 'usnewlock'
(which is downright rude).  So my problem is this:  who is the comedian here,
me or IRIX?

    I have attached a small program that consistently demonstrates my problem
on my system.  It allocates, excercises, and frees N (=100) locks twice: once
as the parent and once as the child.  On my system the child dies (dbx
euphemises that to 'Process xxx (a.out) finished') while nabbing the 87th lock.
I have also tried the program on a 4D-20 (which implements locks in software),
and it works fine with any value of 'N' I have tried (up to almost 700, when 
the arena becomes too small).  So my fear and ignorance are currently aimed 
at hardware locks and their management.

    Which brings me to the whining phase of this message.  What embarassing
assumptions am I making?  Has anyone else had any similar experiences?  Why
are different locks given out during the second run of TestLocks?  Why do 
these things always happen to me?  Any and all comments are welcome, 'cause
I'm stuck real good.

                                                Mike Chapman
                                                mike at snowhite.cis.uoguelph.ca
-------------------cut me, mick----------------------------------------------
#include <stdio.h>
#include <ulocks.h>			/* Don't forget to link -lmpc... */
#include <assert.h>

#define N			100	/* 200 and 1000 caused trouble, too. */
usptr_t *arena;

/*////////////////////////////////////*/
TestLocks()
{
	int i;
	ulock_t lock [N];

	for(i = 0; i < N; i++) {
		lock[i] = usnewlock(arena);
		assert(lock[i] != NULL);
		ussetlock(lock[i]);
		usunsetlock(lock[i]);
		fprintf(stderr, "Tested lock %3d, addr = %d.\n", i, lock[i]);
	}

	for(i = 0; i < N; i++)
		usfreelock(lock[i], arena);

	fprintf(stderr, "Lock test passed.  oo-ra.\n");
}

/*////////////////////////////////////*/
Child()
{
	TestLocks();
	fprintf(stderr, "Child is done.\n");
}

/*////////////////////////////////////*/
main()
{
	int status, i;

	arena = usinit("arena");
	assert(arena != NULL);

	TestLocks();
	status = sproc(Child, PR_SALL);
	assert(status >= 0);

	sleep(60);
	printf("Parent is done.\n");
}



More information about the Comp.sys.sgi mailing list