Skip to content

Commit

Permalink
Initial port of pthread-embedded to Unikraft
Browse files Browse the repository at this point in the history
This is our initial port of pthread-embedded to Unikraft as external
library. For now you need newlib to make it work. When adding the
library in the dependency list, pthread-embedded should stay before
newlib (e.g. ...:$(UK_LIBS)/pthread-embedded:$(UK_LIBS)/newlib.git:...).

Signed-off-by: Costin Lupu <[email protected]>
Reviewed-by: Florian Schmidt <[email protected]>
  • Loading branch information
clupuishere authored and Florian Schmidt committed Jun 4, 2019
1 parent 743ed59 commit 51f10a5
Show file tree
Hide file tree
Showing 8 changed files with 1,031 additions and 0 deletions.
30 changes: 30 additions & 0 deletions Config.uk
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
menuconfig LIBPTHREAD_EMBEDDED
bool "libpthread-embedded - An embedded pthread library"
default n
select LIBNOLIBC if !HAVE_LIBC
select LIBUKDEBUG
select LIBUKALLOC
select LIBUKSCHED
select LIBUKLOCK
select LIBUKLOCK_MUTEX
select LIBUKLOCK_SEMAPHORE

if LIBPTHREAD_EMBEDDED
config LIBPTHREAD_EMBEDDED_MAX_SIMUL_THREADS
int "Maximum number of simultaneous threads"
default 32
help
Maximum number of simultaneous threads.

config LIBPTHREAD_EMBEDDED_MAX_TLS
int "Maximum number of TLS values"
default 32
help
Maximum number of supported TLS values.

config LIBPTHREAD_EMBEDDED_UTEST
bool "Build unit tests"
default n
help
Builds the unit tests for running them from an external application.
endif
327 changes: 327 additions & 0 deletions Makefile.uk

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
pthread-embedded for Unikraft
=============================

This is the port of pthread-embedded for Unikraft as external library. You will
need newlib to make it work. When adding the library in the dependency list,
pthread-embedded should stay before newlib, e.g.:

`...:$(UK_LIBS)/pthread-embedded:$(UK_LIBS)/newlib:...`

For running the unit tests, enable the 'Build unit tests' option in the
configuration menu and call the `pte_test_main()` function in your main
application.

Please refer to the `README.md` as well as the documentation in the `doc/`
subdirectory of the main unikraft repository.
90 changes: 90 additions & 0 deletions exportsyms.uk
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
pthread_init
pthread_terminate
pthread_attr_init
pthread_attr_destroy
pthread_attr_getdetachstate
pthread_attr_getstackaddr
pthread_attr_getstacksize
pthread_attr_setdetachstate
pthread_attr_setstackaddr
pthread_attr_setstacksize
pthread_attr_getschedparam
pthread_attr_setschedparam
pthread_attr_setschedpolicy
pthread_attr_getschedpolicy
pthread_attr_setinheritsched
pthread_attr_getinheritsched
pthread_attr_setscope
pthread_attr_getscope
pthread_create
pthread_detach
pthread_equal
pthread_exit
pthread_join
pthread_self
pthread_cancel
pthread_setcancelstate
pthread_setcanceltype
pthread_testcancel
pthread_once
pthread_key_create
pthread_key_delete
pthread_setspecific
pthread_getspecific
pthread_mutexattr_init
pthread_mutexattr_destroy
pthread_mutexattr_getpshared
pthread_mutexattr_setpshared
pthread_mutexattr_settype
pthread_mutexattr_gettype
pthread_barrierattr_init
pthread_barrierattr_destroy
pthread_barrierattr_getpshared
pthread_barrierattr_setpshared
pthread_mutex_init
pthread_mutex_destroy
pthread_mutex_lock
pthread_mutex_timedlock
pthread_mutex_trylock
pthread_mutex_unlock
pthread_spin_init
pthread_spin_destroy
pthread_spin_lock
pthread_spin_trylock
pthread_spin_unlock
pthread_barrier_init
pthread_barrier_destroy
pthread_barrier_wait
pthread_condattr_init
pthread_condattr_destroy
pthread_condattr_getpshared
pthread_condattr_setpshared
pthread_cond_init
pthread_cond_destroy
pthread_cond_wait
pthread_cond_timedwait
pthread_cond_signal
pthread_cond_broadcast
pthread_setschedparam
pthread_getschedparam
pthread_setconcurrency
pthread_getconcurrency
pthread_rwlock_init
pthread_rwlock_destroy
pthread_rwlock_tryrdlock
pthread_rwlock_trywrlock
pthread_rwlock_rdlock
pthread_rwlock_timedrdlock
pthread_rwlock_wrlock
pthread_rwlock_timedwrlock
pthread_rwlock_unlock
pthread_rwlockattr_init
pthread_rwlockattr_destroy
pthread_rwlockattr_getpshared
pthread_rwlockattr_setpshared
pthread_kill
sched_yield
sched_get_priority_min
sched_get_priority_max
sched_setscheduler
pte_test_main
16 changes: 16 additions & 0 deletions include/pte_osal.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#ifndef __PTE_OSAL_H__
#define __PTE_OSAL_H__

#include <uk/mutex.h>
#include <uk/semaphore.h>

typedef struct uk_thread* pte_osThreadHandle;
typedef struct uk_semaphore *pte_osSemaphoreHandle;
typedef struct uk_mutex *pte_osMutexHandle;

#define OS_MAX_SIMUL_THREADS \
CONFIG_LIBPTHREAD_EMBEDDED_MAX_SIMUL_THREADS

#include "pte_generic_osal.h"

#endif /* __PTE_OSAL_H__ */
10 changes: 10 additions & 0 deletions include/pte_types.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#ifndef __PTE_TYPES_H__
#define __PTE_TYPES_H__

#include <sys/timeb.h>

typedef unsigned int tid_t;

typedef int pid_t;

#endif /* __PTE_TYPES_H__ */
6 changes: 6 additions & 0 deletions include/sys/_pthreadtypes.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#ifndef _SYS__PTHREADTYPES_H_
#define _SYS__PTHREADTYPES_H_

#include <pthread.h>

#endif /* _SYS__PTHREADTYPES_H_ */
Loading

0 comments on commit 51f10a5

Please sign in to comment.