Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
FORMUS3IC_LAS3
/
embb
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
ad97663c
authored
Nov 27, 2014
by
Marcus Winter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mtapi_c: added task completion callback and user_data pointer
parent
c7ba5e6a
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
38 additions
and
6 deletions
+38
-6
mtapi_c/include/embb/mtapi/c/mtapi.h
+20
-6
mtapi_c/src/embb_mtapi_action_t.c
+1
-0
mtapi_c/src/embb_mtapi_scheduler_t.c
+5
-0
mtapi_c/src/mtapi_task_attributes_t.c
+12
-0
No files found.
mtapi_c/include/embb/mtapi/c/mtapi.h
View file @
ad97663c
...
...
@@ -557,6 +557,17 @@ enum mtapi_node_attributes_enum {
#define MTAPI_NODE_TYPE_SMP 1
#define MTAPI_NODE_TYPE_DSP 2
/**
* Task handle type.
* \memberof mtapi_task_hndl_struct
*/
typedef
struct
mtapi_task_hndl_struct
mtapi_task_hndl_t
;
/** task completion callback */
typedef
void
(
*
mtapi_task_complete_function_t
)(
MTAPI_IN
mtapi_task_hndl_t
task
,
MTAPI_OUT
mtapi_status_t
*
status
);
/** task attributes */
enum
mtapi_task_attributes_enum
{
MTAPI_TASK_DETACHED
,
/**< task is detached, i.e., the runtime
...
...
@@ -574,7 +585,9 @@ enum mtapi_task_attributes_enum {
executed n times, if possible in
parallel */
MTAPI_TASK_PRIORITY
,
MTAPI_TASK_AFFINITY
MTAPI_TASK_AFFINITY
,
MTAPI_TASK_USER_DATA
,
MTAPI_TASK_COMPLETE_FUNCTION
};
/** size of the \a MTAPI_TASK_DETACHED attribute */
#define MTAPI_TASK_DETACHED_SIZE sizeof(mtapi_boolean_t)
...
...
@@ -671,6 +684,10 @@ struct mtapi_task_attributes_struct {
mtapi_uint_t
num_instances
;
/**< stores MTAPI_TASK_INSTANCES */
mtapi_uint_t
priority
;
/**< stores MTAPI_TASK_PRIORITY */
mtapi_affinity_t
affinity
;
/**< stores MTAPI_TASK_AFFINITY */
void
*
user_data
;
/**< stores MTAPI_TASK_USER_DATA */
mtapi_task_complete_function_t
complete_func
;
/**< stores
MTAPI_TASK_COMPLETE_FUNCTION */
};
/**
...
...
@@ -869,11 +886,8 @@ struct mtapi_task_hndl_struct {
mtapi_task_id_t
id
;
/**< pool index of this handle */
};
/**
* Task handle type.
* \memberof mtapi_task_hndl_struct
*/
typedef
struct
mtapi_task_hndl_struct
mtapi_task_hndl_t
;
// was forward declared
//typedef struct mtapi_task_hndl_struct mtapi_task_hndl_t;
/* ---- BASIC CONSTANTS ---------------------------------------------------- */
...
...
mtapi_c/src/embb_mtapi_action_t.c
View file @
ad97663c
...
...
@@ -56,6 +56,7 @@ void embb_mtapi_action_initialize(embb_mtapi_action_t* that) {
that
->
enabled
=
MTAPI_FALSE
;
that
->
node_local_data
=
NULL
;
that
->
node_local_data_size
=
0
;
that
->
plugin_data
=
MTAPI_NULL
;
embb_atomic_store_int
(
&
that
->
num_tasks
,
0
);
}
...
...
mtapi_c/src/embb_mtapi_scheduler_t.c
View file @
ad97663c
...
...
@@ -345,6 +345,11 @@ int embb_mtapi_scheduler_worker(void * arg) {
/* do nothing, although this is an error */
break
;
}
/* issue task complete callback if set */
if
(
MTAPI_NULL
!=
task
->
attributes
.
complete_func
)
{
task
->
attributes
.
complete_func
(
task
->
handle
,
MTAPI_NULL
);
}
}
else
if
(
counter
<
1024
)
{
/* spin and yield for a while before going to sleep */
embb_thread_yield
();
...
...
mtapi_c/src/mtapi_task_attributes_t.c
View file @
ad97663c
...
...
@@ -25,6 +25,7 @@
*/
#include <assert.h>
#include <string.h>
#include <embb/mtapi/c/mtapi.h>
...
...
@@ -46,6 +47,7 @@ void mtapi_taskattr_init(
attributes
->
num_instances
=
1
;
attributes
->
is_detached
=
MTAPI_FALSE
;
attributes
->
priority
=
0
;
attributes
->
complete_func
=
MTAPI_NULL
;
mtapi_affinity_init
(
&
attributes
->
affinity
,
MTAPI_TRUE
,
&
local_status
);
}
else
{
local_status
=
MTAPI_ERR_PARAMETER
;
...
...
@@ -90,6 +92,16 @@ void mtapi_taskattr_set(
&
attributes
->
affinity
,
attribute
,
attribute_size
);
break
;
case
MTAPI_TASK_USER_DATA
:
attributes
->
user_data
=
(
void
*
)
attribute
;
local_status
=
MTAPI_SUCCESS
;
break
;
case
MTAPI_TASK_COMPLETE_FUNCTION
:
memcpy
(
&
attributes
->
complete_func
,
&
attribute
,
sizeof
(
void
*
));
local_status
=
MTAPI_SUCCESS
;
break
;
default:
/* attribute unknown */
local_status
=
MTAPI_ERR_ATTR_NUM
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment