Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 278b4a30 in mainline


Ignore:
Timestamp:
2010-05-02T10:41:23Z (11 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master
Children:
7ed8530
Parents:
0c42638
Message:

Add task_hold() and task_release().

Location:
kernel/generic
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/include/proc/task.h

    r0c42638 r278b4a30  
    133133extern task_t *task_create(as_t *, const char *);
    134134extern void task_destroy(task_t *);
     135extern void task_hold(task_t *);
     136extern void task_release(task_t *);
    135137extern task_t *task_find_by_id(task_id_t);
    136138extern int task_kill(task_id_t);
  • kernel/generic/src/proc/task.c

    r0c42638 r278b4a30  
    11/*
    2  * Copyright (c) 2001-2004 Jakub Jermar
     2 * Copyright (c) 2010 Jakub Jermar
    33 * All rights reserved.
    44 *
     
    257257}
    258258
     259/** Hold a reference to a task.
     260 *
     261 * Holding a reference to a task prevents destruction of that task.
     262 *
     263 * @param t             Task to be held.
     264 */
     265void task_hold(task_t *t)
     266{
     267        atomic_inc(&t->refcount);
     268}
     269
     270/** Release a reference to a task.
     271 *
     272 * The last one to release a reference to a task destroys the task.
     273 *
     274 * @param t             Task to be released.
     275 */
     276void task_release(task_t *t)
     277{
     278        if ((atomic_predec(&t->refcount)) == 0)
     279                task_destroy(t);
     280}
     281
    259282/** Syscall for reading task ID from userspace.
    260283 *
Note: See TracChangeset for help on using the changeset viewer.