Howdy, Stranger!

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

Categories

binary lock embedded into a C program (GCC)

CredoCredo Member Posts: 2
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!

Comments

  • Justin BibJustin Bib USAMember Posts: 0

    ________ { http://forcoder.org } free video tutorials and ebooks about [ Java, Ruby, C#, PHP, Delphi, Scratch, Perl, JavaScript, Visual Basic, MATLAB, Swift, Objective-C, PL/SQL, C, C++, Assembly, R, Visual Basic .NET, Python, Go ML, Logo, Clojure, Crystal, Scala, F#, Alice, Prolog, Lisp, Transact-SQL, Bash, Scheme, LabVIEW, Hack, Julia, Rust, Fortran, ABAP, SAS, Erlang, COBOL, Dart, Ada, Awk, FoxPro, VBScript, Apex, Lua, Kotlin, D ] ________

Sign In or Register to comment.