aboutsummaryrefslogtreecommitdiff
path: root/helper
diff options
context:
space:
mode:
authorPetri Savolainen <petri.savolainen@linaro.org>2014-10-02 15:24:41 +0300
committerMaxim Uvarov <maxim.uvarov@linaro.org>2014-10-03 16:38:10 +0400
commitd988593a73cd2882b6ddfa5434e798f89e4b42e0 (patch)
tree0274f07398d60c8db1dee5f99e8e6f5a5796fec2 /helper
parent0e0bcce3b624c3a5afc0cca6b4d02ae940bbe47f (diff)
Added process mode to example app
- Added an option to run odp_example as Linux processes (vs. pthreads) - Removed thread dependency from odp_local_init - Added Linux helpers for forking processes - modified odp_thread.c to allocate global variables from shared memory Signed-off-by: Petri Savolainen <petri.savolainen@linaro.org> Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
Diffstat (limited to 'helper')
-rw-r--r--helper/include/odph_linux.h66
1 files changed, 60 insertions, 6 deletions
diff --git a/helper/include/odph_linux.h b/helper/include/odph_linux.h
index 1ea349a..8671dc0 100644
--- a/helper/include/odph_linux.h
+++ b/helper/include/odph_linux.h
@@ -10,8 +10,9 @@
*
* ODP Linux helper API
*
- * This file is an optional helper to odp.h APIs. Application can manage
- * pthreads also by other means.
+ * This file is an optional helper to odp.h APIs. These functions are provided
+ * to ease common setups in a Linux system. User is free to implement the same
+ * setups in otherways (not via this API).
*/
#ifndef ODP_LINUX_H_
@@ -23,15 +24,24 @@ extern "C" {
#include <pthread.h>
+#include <sys/types.h>
-/** Pthread status data */
+/** Linux pthread state information */
typedef struct {
- pthread_t thread; /**< @private Pthread */
- pthread_attr_t attr; /**< @private Pthread attributes */
-
+ pthread_t thread; /**< Pthread ID */
+ pthread_attr_t attr; /**< Pthread attributes */
+ int core; /**< Core ID */
} odph_linux_pthread_t;
+/** Linux process state information */
+typedef struct {
+ pid_t pid; /**< Process ID */
+ int core; /**< Core ID */
+ int status; /**< Process state change status */
+} odph_linux_process_t;
+
+
/**
* Creates and launches pthreads
*
@@ -61,6 +71,50 @@ void odph_linux_pthread_create(odph_linux_pthread_t *thread_tbl,
void odph_linux_pthread_join(odph_linux_pthread_t *thread_tbl, int num);
+/**
+ * Fork a process
+ *
+ * Forks and sets core affinity for the child process
+ *
+ * @param proc Pointer to process state info (for output)
+ * @param core Destination core for the child process
+ *
+ * @return On success: 1 for the parent, 0 for the child
+ * On failure: -1 for the parent, -2 for the child
+ */
+int odph_linux_process_fork(odph_linux_process_t *proc, int core);
+
+
+/**
+ * Fork a number of processes
+ *
+ * Forks and sets core affinity for child processes
+ *
+ * @param proc_tbl Process state info table (for output)
+ * @param num Number of processes to create
+ * @param first_core Destination core for the first process
+ *
+ * @return On success: 1 for the parent, 0 for the child
+ * On failure: -1 for the parent, -2 for the child
+ */
+int odph_linux_process_fork_n(odph_linux_process_t *proc_tbl,
+ int num, int first_core);
+
+
+/**
+ * Wait for a number of processes
+ *
+ * Waits for a number of child processes to terminate. Records process state
+ * change status into the process state info structure.
+ *
+ * @param proc_tbl Process state info table (previously filled by fork)
+ * @param num Number of processes to wait
+ *
+ * @return 0 on success, -1 on failure
+ */
+int odph_linux_process_wait_n(odph_linux_process_t *proc_tbl, int num);
+
+
#ifdef __cplusplus
}
#endif