On 02/12/2015 05:59 PM, Cyril Hrubis wrote: > Hi! > Code prototype follows. It uses mutexes and can be used with up to > page_size/sizeof(uint32) pairs. I've checked that it compiles fine and > works back to kernel 2.6.11 compiled in year 2005, which should be more > than enough. > > It uses a regular file as a backing for the shared pages which makes it > even easier to replace the fifo based solution we have. All that is > needed is to map the same file created in the test temporary directory > just like the fifo does. > > Please anone that uses LTP, check that the code compiles and works for > fine on all distributions you care for. Once that is checked, I will > write the new library functions based on this code and convert all the > test to the new interface.
Thanks, works for me. Some notes; I assume you used syscall(SYS_futex, ..) instead of pthread_mutex (which uses it internally) because of the linking simplicity, right? Fair tradeoff. No idea what you're going to use for the final code, but I'd default to perror("open()"); instead of fprintf(stderr, "open(): %s\n", strerror(errno)); (you also don't need errno.h for the former one). > > > tfutex.c > > > #include <fcntl.h> > #include <stdint.h> > #include <unistd.h> > #include <limits.h> > #include <sys/types.h> > #include <sys/stat.h> > #include <sys/mman.h> > #include <sys/syscall.h> > #include <linux/futex.h> > > #include <stdio.h> > #include <string.h> > #include <errno.h> > #include <stdlib.h> > > typedef volatile uint32_t futex_t; > > static futex_t *futexes; > > static void finit(void) > { > int fd; > > fd = open("/tmp/syncronization_futex_base_file", O_RDWR | O_CREAT, > 0666); > > if (fd < 0) { > fprintf(stderr, "open(): %s\n", strerror(errno)); > exit(1); > } ------------------------------------------------------------------------------ Dive into the World of Parallel Programming. The Go Parallel Website, sponsored by Intel and developed in partnership with Slashdot Media, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials and more. Take a look and join the conversation now. http://goparallel.sourceforge.net/ _______________________________________________ Ltp-list mailing list Ltp-list@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/ltp-list