* It can also happen if this is a buffer we never got. */
return -EIO;
} else {
- if(atomic_inc_return(<t_buf->writer_futex) <= 0) {
- atomic_set(<t_buf->writer_futex, 1);
- /* tell the client that buffer is now unfull */
- ret = futex((unsigned long)<t_buf->writer_futex,
- FUTEX_WAKE, 1, 0, 0, 0);
- if(ret != 1) {
- dbg_printf("LTT warning : race condition : writer not waiting or too many writers\n");
- }
+ ret = sem_post(<t_buf->writer_sem);
+ if(ret < 0) {
+ printf("error in sem_post");
}
}
}
static void ltt_usertrace_fast_daemon(struct ltt_trace_info *shared_trace_info,
sigset_t oldset, pid_t l_traced_pid, pthread_t l_traced_tid)
{
+ sigset_t set;
struct sigaction act;
int ret;
int fd_process;
sigaddset(&(act.sa_mask), SIGALRM);
sigaction(SIGALRM, &act, NULL);
- /* Enable signals */
- ret = pthread_sigmask(SIG_SETMASK, &oldset, NULL);
- if(ret) {
- dbg_printf("LTT Error in pthread_sigmask\n");
- }
-
alarm(3);
/* Open output files */
#endif //LTT_NULL_OUTPUT_TEST
while(1) {
- pause();
+ ret = sigsuspend(&oldset);
+ if(ret != -1) {
+ perror("LTT Error in sigsuspend\n");
+ }
+
if(traced_pid == 0) break; /* parent died */
if(parent_exited) break;
dbg_printf("LTT Doing a buffer switch read. pid is : %lu\n", getpid());
-
+
do {
ret = read_subbuffer(&shared_trace_info->channel.process, fd_process);
} while(ret == 0);
close(fd_process);
+ ret = sem_destroy(&shared_trace_info->channel.process.writer_sem);
+ if(ret < 0) {
+ perror("error in sem_destroy");
+ }
munmap(shared_trace_info, sizeof(*shared_trace_info));
exit(0);
shared_trace_info->nesting=0;
memset(&shared_trace_info->channel.process, 0,
sizeof(shared_trace_info->channel.process));
- /* Tricky semaphore : is in a shared memory space, so it's ok for a fast
- * mutex (futex). */
- atomic_set(&shared_trace_info->channel.process.writer_futex, LTT_N_SUBBUFS);
+ //Need NPTL!
+ ret = sem_init(&shared_trace_info->channel.process.writer_sem, 1,
+ LTT_N_SUBBUFS);
+ if(ret < 0) {
+ perror("error in sem_init");
+ }
shared_trace_info->channel.process.alloc_size = LTT_BUF_SIZE_PROCESS;
shared_trace_info->channel.process.subbuf_size = LTT_SUBBUF_SIZE_PROCESS;
shared_trace_info->channel.process.start =