[techtalk] Intro (Q's on m68k, beowulf, SMP programming, and databases)

Serena Del Bianco serena at serena.dhis.org
Wed Oct 20 17:47:15 EST 1999


On Fri, 22 Oct 1999, TeknoDragon wrote:

> Greetings,
> 
> My wife (guess who!) seems to enjoy this list a lot so I thought I'd join
> up (I seem to be doing this frequently). I'm Karl (aka Andross/TeknoDragon
> depending on the medium of participation) a CS undergrad at WSU and a
> "technopagan".
> 
> Right now I'm trying to squeeze MacOS down into 1024k or so so that I can
> install m68k on a 4MB SE/30. I think i'm close, but every combination of
> enabled and disabled extensions seems to result in memory usage, perhaps
> I'll just go find some more ram.
> 
> I'm working on a database library idea and started investigated record
> locking. I've got a system designed that's much lower level than
> semiphores (which I'd need one for every record or a semaphored record
> locking queue if I did it that way!) and hinges on the "testset" function
> that my unix programming prof told me about. The only problem is that
> testset doesn't seem to be in any manual or piece of documentation that I
> can easily find. I'm thinking something like this: (which I might be able
> to use as long as it's an attomic function and I'm not using SMP)
> 
> char testset(char *x){
> 	if(*x == 0) x++;
> 	else return x;
> 	return 0;
> }

that wont work if you're using threads either
imagine that thread 1 tries to execute that code and x is 0
it will execute (*x == 0) and it will see the expression is true and will
execute x++ then, thread 1 is preempted and thread 2 starts executing
this time x is 1, coz thread 1 incremented it
so instead of running x++, it will return x
that's what normally should happen
but if you're unlucky and thread 2 starts executing right after (*x == 0)
executed and before x++ x will still be 0
so it will test the expression, will see it's true and will do x++
then thread 1 resumes execution and finishes doing x++
In this case the value of x will be 2 instead of 1, like in the other case
And that's evil


Serena Del Bianco


************
techtalk at linuxchix.org   http://www.linuxchix.org




More information about the Techtalk mailing list