Skip to content
Raphaël POGGI edited this page Dec 22, 2018 · 6 revisions

Kernel API interface is intended to be used in trusted code (drivers, filesystem implementation, etc.) whereas user interface is for user application which will be load at runtime.

Scheduler

  • void schedule_yield(void)

Thread

User interface:

  • int pthread_create(pthread_t *thread, void (*start_routine)(void *), void *arg, unsigned int priority)
  • int pthread_join(pthread_t *thread, void **retval)

Kernel interface:

  • struct thread *thread_create(void (*func)(void), void *arg, unsigned int priority)
  • struct thread *add_thread(void (*func)(void), void *arg, unsigned int priority, int privileged)
  • int thread_join(struct thread *t)

Mutex

Kernel interface:

Mutex should NOT be used from interrupt handler

  • int kmutex_init(struct mutex *mutex)
  • int kmutex_lock(struct mutex *mutex)
  • int kmutex_unlock(struct mutex *mutex)

User interface:

  • int pthread_mutex_init(pthread_mutex_t *mutex)
  • int pthread_mutex_lock(pthread_mutex_t *mutex)
  • int pthread_mutex_unlock(pthread_mutex_t *mutex)

Semaphore

Kernel interface:

  • int ksem_init(struct semaphore *sem, int value)
  • int ksem_wait(struct semaphore *sem)
  • int ksem_post(struct semaphore *sem)
  • int ksem_post_isr(struct semaphore *sem)

User interface:

  • void sem_init(sem_t *sem, unsigned int value)
  • void sem_wait(sem_t *sem)
  • void sem_post(sem_t *sem)

Queue

Kernel interface:

  • int kqueue_init(struct queue *queue, unsigned int size, unsigned int item_size)
  • int kqueue_clear(struct queue *queue)
  • int kqueue_destroy(struct queue *queue)
  • int kqueue_update(struct queue *queue, unsigned int size, unsigned int item_size)
  • int kqueue_post(struct queue *queue, void *item, unsigned int timeout)
  • int kqueue_receive(struct queue *queue, void *item, unsigned int timeout)

User interface:

  • mqd_t mq_open(const char *name, int flags, ...)
  • int mq_close(mqd_t fd)
  • int mq_getattr(mqd_t fd, struct mq_attr *attr)
  • int mq_setattr(mqd_t fd, const struct mq_attr *attr, struct mq_attr *oldattr)
  • int mq_receive(mqd_t fd, char *msg, size_t msg_len, unsigned int msg_prio)
  • int mq_send(mqd_t fd, const char *msg, size_t msg_len, unsigned int msg_prio)

Wait queue

Wait queue are generic objects used by mutex and semaphore to implement waiting mechanism

Kernel interface:

  • int wait_queue_block_irqstate(struct wait_queue *wait, unsigned long *irqstate)
  • int wait_queue_block(struct wait_queue *wait)
  • int wait_queue_wake_irqstate(struct wait_queue *wait, unsigned long *irqstate)
  • int wait_queue_wake(struct wait_queue *wait)
Clone this wiki locally