Changeset b22b0a94 in mainline


Ignore:
Timestamp:
2019-08-07T05:39:54Z (5 years ago)
Author:
Matthieu Riolo <matthieu.riolo@…>
Children:
b8341bc
Parents:
5cd2290
git-author:
Michal Koutný <xm.koutny+hos@…> (2015-10-19 21:34:52)
git-committer:
Matthieu Riolo <matthieu.riolo@…> (2019-08-07 05:39:54)
Message:

task: Inoperative API for passing kernel task events to uspace

  • Based on user-provided callback function.
  • Includes slight refactoring of tester application code.

Conflicts:

uspace/lib/c/include/task.h

Location:
uspace
Files:
2 added
8 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/tester/Makefile

    r5cd2290 rb22b0a94  
    6868        chardev/chardev1.c \
    6969        proc/dummy_task.c \
     70        proc/task_anywait.c \
    7071        proc/task_wait.c
    7172
  • uspace/app/tester/proc/common.h

    r5cd2290 rb22b0a94  
    4444#define STR_JOB_OK      "job-ok"
    4545
     46#define DUMMY_TASK     "/root/app/tester"
     47#define DUMMY_TASK_ARG "proc_dummy_task"
     48
     49static inline int dummy_task_spawn(task_id_t *task_id, task_wait_t *wait,
     50    const char *behavior)
     51{
     52        return task_spawnl(task_id, wait,
     53            DUMMY_TASK, DUMMY_TASK, DUMMY_TASK_ARG, behavior,
     54            NULL);
     55}
     56
    4657#endif
  • uspace/app/tester/proc/task_wait.c

    r5cd2290 rb22b0a94  
    3636#include "common.h"
    3737
    38 #define DUMMY_TASK     "/root/app/tester"
    39 #define DUMMY_TASK_ARG "proc_dummy_task"
    40 
    41 #define S(x) #x
    42 #define S_(x) S(x)
    43 #define S__LINE__ S_(__LINE__)
    44 
    45 #define TASSERT(expr) \
    46         do { \
    47                 if (!(expr)) \
    48                         return "Failed " #expr " " __FILE__ ":" S__LINE__ ; \
    49         } while (0)
    50 
    51 static int dummy_task_spawn(task_id_t *task_id, task_wait_t *wait,
    52     const char *behavior)
    53 {
    54         return task_spawnl(task_id, wait,
    55             DUMMY_TASK, DUMMY_TASK, DUMMY_TASK_ARG, behavior,
    56             NULL);
    57 }
    5838
    5939const char *test_proc_task_wait(void)
  • uspace/app/tester/tester.c

    r5cd2290 rb22b0a94  
    7979#include "chardev/chardev1.def"
    8080#include "proc/dummy_task.def"
     81#include "proc/task_anywait.def"
    8182#include "proc/task_wait.def"
    8283        {NULL, NULL, NULL, false}
  • uspace/app/tester/tester.h

    r5cd2290 rb22b0a94  
    7070        } while (0)
    7171
     72#define S(x) #x
     73#define S_(x) S(x)
     74#define S__LINE__ S_(__LINE__)
     75
     76#define TASSERT(expr) \
     77        do { \
     78                if (!(expr)) \
     79                        return "Failed " #expr " " __FILE__ ":" S__LINE__ ; \
     80        } while (0)
     81
     82
    7283typedef const char *(*test_entry_t)(void);
    7384
     
    112123extern const char *test_chardev1(void);
    113124extern const char *test_proc_dummy_task(void);
     125extern const char *test_proc_task_anywait(void);
    114126extern const char *test_proc_task_wait(void);
    115127
  • uspace/lib/c/generic/task.c

    r5cd2290 rb22b0a94  
    33 * Copyright (c) 2008 Jiri Svoboda
    44 * Copyright (c) 2014 Martin Sucha
     5 * Copyright (c) 2015 Michal Koutny
    56 * All rights reserved.
    67 *
     
    5354
    5455static async_sess_t *session_taskman = NULL;
     56static task_event_handler_t task_event_handler = NULL;
    5557
    5658task_id_t task_get_id(void)
     
    470472}
    471473
     474void task_set_event_handler(task_event_handler_t handler)
     475{
     476        task_event_handler = handler;
     477        // TODO implement logic for calling the handler
     478}
    472479
    473480void __task_init(async_sess_t *sess)
  • uspace/lib/c/include/task.h

    r5cd2290 rb22b0a94  
    4646#define TASK_WAIT_BOTH   0x4
    4747
    48 typedef struct {
    49         int flags;
    50         ipc_call_t result;
    51         aid_t aid;
    52         task_id_t tid;
    53 } task_wait_t;
    54 
    5548static inline void task_wait_set(task_wait_t *wait, int flags)
    5649{
     
    7669    __attribute__((sentinel));
    7770
    78 // if there is possibility for further wait, modify task_wait
    7971extern errno_t task_wait(task_wait_t *, task_exit_t *, int *);
    8072extern errno_t task_wait_task_id(task_id_t, int, task_exit_t *, int *);
    81 // similar to listen and socket duplication
    82 extern errno_t task_wait_any(task_wait_t *, task_id_t *, task_exit_t *, int *,
    83     task_wait_t *);
    84 
    85 //extern int task_wait_any(int, task_exit_t *, int *);
    86 // alternative
    87 // task_wait_t is output param, actual result is obtained via task_wait call
    88 //extern int task_wait_any(task_wait_t *, int);
    8973
    9074extern void task_cancel_wait(task_wait_t *);
    9175
    9276extern errno_t task_retval(int);
     77extern void task_set_event_handler(task_event_handler_t);
    9378
    9479#endif
  • uspace/lib/c/include/types/task.h

    r5cd2290 rb22b0a94  
    4242} task_exit_t;
    4343
     44typedef struct {
     45        int flags;
     46        ipc_call_t result;
     47        aid_t aid;
     48        task_id_t tid;
     49} task_wait_t;
     50
     51typedef void (* task_event_handler_t)(task_id_t, int, task_exit_t, int);
     52
    4453#endif
    4554
Note: See TracChangeset for help on using the changeset viewer.