All of lore.kernel.org
 help / color / mirror / Atom feed
* [Xenomai-help] shm_open, ftruncate
@ 2006-06-02 15:29 Lionel Perrin
  2006-06-02 16:29 ` Gilles Chanteperdrix
  2006-06-02 17:17 ` Gilles Chanteperdrix
  0 siblings, 2 replies; 14+ messages in thread
From: Lionel Perrin @ 2006-06-02 15:29 UTC (permalink / raw)
  To: xenomai

Hi,

I got some problems with shared memory.
I started from the shm_open example from opengroup.org.
When I compile it as non real time tasks, it works properly. But since I 
tried to compile it with
gcc $(xeno-config --posix-cflags) shm_open.c $(xeno-config 
--posix-ldflags) -o xeno_shm_open,
i get an EINVAL error from ftruncate that i can fix.

Does shm under xenomai require particular things ?

Thanks for your help...

Lionel

#include <unistd.h>
#include <sys/mman.h>
...


#define MAX_LEN 10000
struct region {        /* Defines "structure" of shared memory */
    int len;
    char buf[MAX_LEN];
};
struct region *rptr;
int fd;


/* Create shared memory object and set its size */


fd = shm_open("/myregion", O_CREAT | O_RDWR, S_IRUSR | S_IWUSR);
if (fd == -1)
    /* Handle error */;


if (ftruncate(fd, sizeof(struct region)) == -1)
    /* Handle error */;


/* Map shared memory object */


rptr = mmap(NULL, sizeof(struct region),
       PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
if (rptr == MAP_FAILED)
    /* Handle error */;


/* Now we can refer to mapped region using fields of rptr;
   for example, rptr->len */




^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2006-06-09 13:18 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-06-02 15:29 [Xenomai-help] shm_open, ftruncate Lionel Perrin
2006-06-02 16:29 ` Gilles Chanteperdrix
2006-06-02 17:17 ` Gilles Chanteperdrix
2006-06-05 13:49   ` Lionel Perrin
2006-06-05 15:55     ` Gilles Chanteperdrix
2006-06-06 11:53       ` Lionel Perrin
2006-06-06 12:21         ` Gilles Chanteperdrix
     [not found]           ` <44859C28.3090600@domain.hid>
     [not found]             ` <17541.49945.431732.834139@domain.hid>
2006-06-07 12:55               ` Lionel Perrin
2006-06-07 14:52                 ` Gilles Chanteperdrix
2006-06-09  8:56                   ` Lionel Perrin
2006-06-09 11:46                     ` Gilles Chanteperdrix
2006-06-09 12:28                     ` Gilles Chanteperdrix
2006-06-09 13:18                       ` Lionel Perrin
2006-06-06 18:08         ` Gilles Chanteperdrix

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.