InterruptLock() and InterruptUnlock()

Hai all,

Can any body help me to modifiy this codes, Every time I debug, the process terminated when calling memset().
Could you all give me sample code for using InterruptLock() and InterruptUnlock() functions.?

#include
#include
#include <sys/neutrino.h>
#include <string.h>

int main(int argc, char *argv[]) {

intrspin_t* spinlock ;
memset( spinlock, 0, sizeof( *spinlock ) );
InterruptLock(  spinlock );

printf("critcal data modification\n");
//sleep(3);

InterruptUnlock(spinlock);
return EXIT_SUCCESS;

}

Need help
arms

Updated!!!
Hai all,

Can any body help me to modifiy this codes, Every time I debug, the process terminated when calling memset().
Could you all give me sample code for using InterruptLock() and InterruptUnlock() functions.?

#include
#include
#include <sys/neutrino.h>
#include <string.h>

int main(int argc, char *argv[]) {

intrspin_t* spinlock ;
memset( spinlock, 0, sizeof( *spinlock ) );

ThreadCtl( _NTO_TCTL_IO, NULL );

InterruptLock( spinlock );

printf(“critcal data modification\n”);
//sleep(3);

InterruptUnlock(spinlock);
return EXIT_SUCCESS;
}

Need help
arms

u definitely need to allocate the spinlock:

intrspin_t* spinlock ; spinlock = (intrspin_t*)malloc(sizeof(intrspin_t)); memset( spinlock, 0, sizeof( *spinlock ) );

Thanks a lot mezek!.. :wink:

Or declare as a normal variable instead of a pointer. Spinlock are really small and not worth the overhead of malloc. Plus you don’t need to check for null pointers.