Skip to content

Commit

Permalink
helper: linux: deprecate process fork and join functions
Browse files Browse the repository at this point in the history
Deprecate unused odph_linux_process_fork(), odph_linux_process_fork_n(),
and odph_linux_process_wait_n() functions which have been replaced by
generic odph_thread_create() and odph_thread_join() functions.

Signed-off-by: Matias Elo <[email protected]>
  • Loading branch information
MatiasElo committed Nov 22, 2024
1 parent 72dfb14 commit d247281
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 30 deletions.
15 changes: 0 additions & 15 deletions doc/implementers-guide/implementers-guide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -563,21 +563,6 @@ In the linux helper, two functions are given to create and join ODP threads:
These two functions abstract what an ODP thread really is and their usage
is recommended as they would be implemented in other OS`s helper lib.

Five older functions exist to tie and ODP thread to a specific implementation:

`odph_linux_pthread_create()`

`odph_linux_pthread_join()`

`odph_linux_process_fork_n()`

`odph_linux_process_fork()`

`odph_linux_process_wait_n()`

The usage of these functions should not occur within ODP examples nor tests.
The usage of these functions in other application is not recommended.

[[typedefs]]
== ODP Abstract Types and Implementation Typedefs
ODP APIs are defined to be abstract and operate on abstract types. For example,
Expand Down
19 changes: 13 additions & 6 deletions helper/include/odp/helper/linux/process.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#ifndef ODPH_LINUX_PROCESS_H_
#define ODPH_LINUX_PROCESS_H_

#include <odp/helper/deprecated.h>
#include <odp/helper/threads.h>
#include <odp_api.h>

Expand All @@ -39,9 +40,11 @@ extern "C" {
*
* @return On success: 1 for the parent, 0 for the child
* On failure: -1 for the parent, -2 for the child
*
* @deprecated Use odph_thread_create() instead.
*/
int odph_linux_process_fork(odph_linux_process_t *proc, int cpu,
const odph_linux_thr_params_t *thr_params);
int ODPH_DEPRECATE(odph_linux_process_fork)(odph_linux_process_t *proc, int cpu,
const odph_linux_thr_params_t *thr_params);

/**
* Fork a number of processes
Expand All @@ -55,10 +58,12 @@ int odph_linux_process_fork(odph_linux_process_t *proc, int cpu,
*
* @return On success: 1 for the parent, 0 for the child
* On failure: -1 for the parent, -2 for the child
*
* @deprecated Use odph_thread_create() instead.
*/
int odph_linux_process_fork_n(odph_linux_process_t *proc_tbl,
const odp_cpumask_t *mask,
const odph_linux_thr_params_t *thr_params);
int ODPH_DEPRECATE(odph_linux_process_fork_n)(odph_linux_process_t *proc_tbl,
const odp_cpumask_t *mask,
const odph_linux_thr_params_t *thr_params);

/**
* Wait for a number of processes
Expand All @@ -70,8 +75,10 @@ int odph_linux_process_fork_n(odph_linux_process_t *proc_tbl,
* @param num Number of processes to wait
*
* @return 0 on success, -1 on failure
*
* @deprecated Use odph_thread_join() instead.
*/
int odph_linux_process_wait_n(odph_linux_process_t *proc_tbl, int num);
int ODPH_DEPRECATE(odph_linux_process_wait_n)(odph_linux_process_t *proc_tbl, int num);

/**
* @}
Expand Down
14 changes: 7 additions & 7 deletions helper/linux/thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@ void ODPH_DEPRECATE(odph_linux_pthread_join)(odph_linux_pthread_t *thread_tbl, i
}
}

int odph_linux_process_fork_n(odph_linux_process_t *proc_tbl,
const odp_cpumask_t *mask,
const odph_linux_thr_params_t *thr_params)
int ODPH_DEPRECATE(odph_linux_process_fork_n)(odph_linux_process_t *proc_tbl,
const odp_cpumask_t *mask,
const odph_linux_thr_params_t *thr_params)
{
pid_t pid;
int num;
Expand Down Expand Up @@ -184,17 +184,17 @@ int odph_linux_process_fork_n(odph_linux_process_t *proc_tbl,
return 1;
}

int odph_linux_process_fork(odph_linux_process_t *proc, int cpu,
const odph_linux_thr_params_t *thr_params)
int ODPH_DEPRECATE(odph_linux_process_fork)(odph_linux_process_t *proc, int cpu,
const odph_linux_thr_params_t *thr_params)
{
odp_cpumask_t mask;

odp_cpumask_zero(&mask);
odp_cpumask_set(&mask, cpu);
return odph_linux_process_fork_n(proc, &mask, thr_params);
return ODPH_DEPRECATE(odph_linux_process_fork_n)(proc, &mask, thr_params);
}

int odph_linux_process_wait_n(odph_linux_process_t *proc_tbl, int num)
int ODPH_DEPRECATE(odph_linux_process_wait_n)(odph_linux_process_t *proc_tbl, int num)
{
pid_t pid;
int i, j;
Expand Down
4 changes: 2 additions & 2 deletions helper/test/linux/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ int main(int argc ODP_UNUSED, char *argv[] ODP_UNUSED)
thr_params.instance = instance;

/* Fork worker processes */
ret = odph_linux_process_fork_n(proc, &cpu_mask, &thr_params);
ret = ODPH_DEPRECATE(odph_linux_process_fork_n)(proc, &cpu_mask, &thr_params);

if (ret < 0) {
ODPH_ERR("Fork workers failed %i\n", ret);
Expand All @@ -87,7 +87,7 @@ int main(int argc ODP_UNUSED, char *argv[] ODP_UNUSED)
}
} else {
/* Parent process */
odph_linux_process_wait_n(proc, num_workers);
ODPH_DEPRECATE(odph_linux_process_wait_n)(proc, num_workers);

if (odp_term_local()) {
ODPH_ERR("Error: ODP local term failed.\n");
Expand Down

0 comments on commit d247281

Please sign in to comment.