logo

Could not compile stylesheet for simplistic. Using last compiled stylesheet.
Question
peter
peter
Offline
0
Hi ....
I am trying to implement a binary semaphore on igepv2 to control access to shared memory containing accelerometer and gps data. The test code (shown below) works fine on ubuntu but gives "Function not available" on igepv2. Do I need to tweak something to get it working or is there a better way (eg spinlocks) that will work?

I really appreciate your help and support!

Peter

#define SEMAPHORE "semaphor999"

#include
#include
#include
#include
#include

main()
{
sem_t *fxsemaphor;
int i, err;
int semvalue;

fxsemaphor = sem_open(SEMAPHORE, O_CREAT, 0644, 1);
if(fxsemaphor == SEM_FAILED){
perror("sem_open failure");
// getting errno 38 "Function not implemented" on igepv2
printf("error \n");
exit(0);
}

sem_getvalue(fxsemaphor, &semvalue);
printf("got here semaphore = %d \n", semvalue );

sem_wait(fxsemaphor); // start semaphore and critical code

for(i=0; i<10; i++)
{
sem_getvalue(fxsemaphor, &semvalue);
printf("semaphore = %d \n", semvalue );
printf("critical code here \n");
printf("process id %d, and parent process id %d \n",
getpid(), getppid() );
sleep(2);
}

sem_post(fxsemaphor); // release semaphore end critical code

sem_getvalue(fxsemaphor, &semvalue);
printf("got here semaphore = %d \n", semvalue );

sem_close(fxsemaphor); // close the semaphore
err = sem_unlink(SEMAPHORE); // get rid of semaphore
if(err == -1)
perror("sem_unlink failure");

}
Responses (4)
  • Accepted Answer

    mcaro
    mcaro
    Offline
    Wednesday, June 11 2014, 01:34 PM - #permalink
    0
    Hi Peter,

    What kernel version are you using ?

    Did you build the kernel ? if the answer is yes then Can you attach your .config file ?

    Manel
    The reply is currently minimized Show
  • Accepted Answer

    peter
    peter
    Offline
    Wednesday, June 11 2014, 02:25 PM - #permalink
    0
    Hi Manel,
    I have 2 igepv2 boards. One is my build, The other is "out of the box" from ISEE. They both give the same error message "Function not found"

    IGEPv2 Board #1- my build
    My build is linux-omap-2.6.37-6 - the .config (myconfig) is attached and my bootargs are below.


    IGEPv2 Board #2 - out of the box from ISEE
    uname -r = 2.6.37


    Thanks for you help...
    Peter

    bootargs=console=tty0 console=ttyO2,115200 root=/dev/nfs ip=192.168.0.100:192.168.0.1::255.255.255.0::eth0: smsc911x.mac=0xb2,0xb0,0x14,0xb5,0xcd,0xde nfsroot=192.168.0.1:/home/peter/Documents/felabs/sysdev/buildsdl/pmtroot omapfb.mode=dvi:1280x720MR-16@60 omapdss.def_disp=dvi
    Attachments:
    The reply is currently minimized Show
  • Accepted Answer

    mcaro
    mcaro
    Offline
    Wednesday, June 11 2014, 03:16 PM - #permalink
    0
    Hi Peter,

    I tested your code and this is the output, tested with kernel 2.6.37-9 and attached you've the config used ...

    root@igep00x0:~# ./t
    got here semaphore = 1
    semaphore = 0
    critical code here
    process id 1441, and parent process id 1369
    semaphore = 0
    critical code here
    process id 1441, and parent process id 1369
    semaphore = 0
    critical code here
    process id 1441, and parent process id 1369
    semaphore = 0
    critical code here
    process id 1441, and parent process id 1369
    semaphore = 0
    critical code here
    process id 1441, and parent process id 1369
    semaphore = 0
    critical code here
    process id 1441, and parent process id 1369
    semaphore = 0
    critical code here
    process id 1441, and parent process id 1369
    semaphore = 0
    critical code here
    process id 1441, and parent process id 1369
    semaphore = 0
    critical code here
    process id 1441, and parent process id 1369
    semaphore = 0
    critical code here
    process id 1441, and parent process id 1369
    got here semaphore = 1
    

    Manel
    Attachments:
    The reply is currently minimized Show
  • Accepted Answer

    mcaro
    mcaro
    Offline
    Wednesday, June 11 2014, 05:40 PM - #permalink
    0
    Hi Peter,

    What root filesystem (distribution) are you using ?

    Manel
    The reply is currently minimized Show
Your Reply

SUPPORT


This email address is being protected from spambots. You need JavaScript enabled to view it.
This email address is being protected from spambots. You need JavaScript enabled to view it.
IGEP Community Wiki
IGEP Community Forum
IGEP Community Online Chat