Lines Matching defs:sync
3 * Helper functions to sync execution between parent and child processes.
29 #define CHILD_FAIL_IF(x, sync) \
34 (sync)->child_gave_up = true; \
35 prod_parent(sync); \
40 #define PARENT_FAIL_IF(x, sync) \
45 (sync)->parent_gave_up = true; \
46 prod_child(sync); \
51 #define PARENT_SKIP_IF_UNSUPPORTED(x, sync, msg) \
54 (sync)->parent_gave_up = true; \
55 prod_child(sync); \
60 int init_child_sync(struct child_sync *sync)
64 ret = sem_init(&sync->sem_parent, 1, 0);
70 ret = sem_init(&sync->sem_child, 1, 0);
79 void destroy_child_sync(struct child_sync *sync)
81 sem_destroy(&sync->sem_parent);
82 sem_destroy(&sync->sem_child);
85 int wait_child(struct child_sync *sync)
90 ret = sem_wait(&sync->sem_parent);
96 return sync->child_gave_up;
99 int prod_child(struct child_sync *sync)
104 ret = sem_post(&sync->sem_child);
113 int wait_parent(struct child_sync *sync)
118 ret = sem_wait(&sync->sem_child);
124 return sync->parent_gave_up;
127 int prod_parent(struct child_sync *sync)
132 ret = sem_post(&sync->sem_parent);