binary lock embedded into a C program (GCC)

I am a total newbie with assembly and I need an atomic binary locking routine to my application. It'll be written in C and will run on a Pentium 2. I use GCC 2.9.* -compiler in Red Hat Linux. I suppose I shoul use the bts-command but thats about all I know.

The program should look something like this:

// structure for various bits
typedef struct bits{
unsigned int lock_variable : 1
...
} BITS;

...

BITS *some_bitfield = (BITS) malloc (...);

// call for acquiring the lock
while (acquire_lock() == -1){
write (2, "busy
", 5);
}

// acquire_lock -function
int acquire_lock (some_bitfield){

asm (
?
);

return i;
}

Thanks for any help!
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories