diff options
author | Dimitri John Ledkov <xnox@ubuntu.com> | 2018-12-11 10:30:30 +1100 |
---|---|---|
committer | Dimitri John Ledkov <xnox@ubuntu.com> | 2018-12-11 10:30:30 +1100 |
commit | 59d2f4ec0b9dff7b56da34541dffd3e676adf584 (patch) | |
tree | 0f982d10b206f248f13de6ba48617e9bdae5e5f5 /task-utils.c | |
parent | 3b9cf4c8cda0818e4d3f9892ece9f7d99de13b03 (diff) | |
parent | 5b162a39be9dec46a22c815f43fc337b920b4252 (diff) |
Update upstream source from tag 'upstream/4.19.1'
Update to upstream version '4.19.1'
with Debian dir 171bf4d92c150acf94e8e0a7633c4349c4e39ad6
Diffstat (limited to 'task-utils.c')
-rw-r--r-- | task-utils.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/task-utils.c b/task-utils.c index 12b00027..e4dcd36b 100644 --- a/task-utils.c +++ b/task-utils.c @@ -19,6 +19,7 @@ #include <stdio.h> #include <stdlib.h> #include <unistd.h> +#include <time.h> #include "task-utils.h" @@ -37,7 +38,7 @@ struct task_info *task_init(void *(*threadfn)(void *), int (*postfn)(void *), return info; } -int task_start(struct task_info *info) +int task_start(struct task_info *info, time_t *start_time, u64 *item_count) { int ret; @@ -47,6 +48,11 @@ int task_start(struct task_info *info) if (!info->threadfn) return -1; + if (start_time) + *start_time = time(NULL); + if (item_count) + *item_count = 0; + ret = pthread_create(&info->id, NULL, info->threadfn, info->private_data); @@ -61,7 +67,7 @@ void task_stop(struct task_info *info) if (!info) return; - if (info->id > 0) { + if (info->id) { pthread_cancel(info->id); pthread_join(info->id, NULL); info->id = 0; @@ -102,7 +108,7 @@ int task_period_start(struct task_info *info, unsigned int period_ms) info->periodic.wakeups_missed = 0; sec = period_ms / 1000; - ns = (period_ms - (sec * 1000)) * 1000; + ns = (period_ms - (sec * 1000)) * 1000 * 1000; itval.it_interval.tv_sec = sec; itval.it_interval.tv_nsec = ns; itval.it_value.tv_sec = sec; |