]> xenbits.xensource.com Git - unikraft/libs/pthread-embedded.git/log
unikraft/libs/pthread-embedded.git
23 months agoAdapt to new scheduling API RELEASE-0.13.0 RELEASE-0.13.1 RELEASE-0.14.0
Eduard Vintilă [Wed, 23 Nov 2022 18:44:26 +0000 (20:44 +0200)]
Adapt to new scheduling API

Signed-off-by: Eduard Vintilă <eduard.vintila47@gmail.com>
Reviewed-by: Maria Sfiraiala <maria.sfiraiala@gmail.com>
Reviewed-by: Teodor Tiron <teotiron@gmail.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #11

3 years agoFix use-after-free in glue code for pthread_join RELEASE-0.10.0 RELEASE-0.12.0 RELEASE-0.8.0 RELEASE-0.9.0
Marc Rittinghaus [Thu, 27 Jan 2022 10:07:58 +0000 (11:07 +0100)]
Fix use-after-free in glue code for pthread_join

When pthread_join is called, we use uk_thread_wait to wait for the
thread to exit. However, this will also release the thread and the
metadata for the pthread in the glue code. pthread_join then calls
pthread_detach, which attempts another wait, accessing the freed
thread.

The commit changes the pte_osThreadHandle to point to the
metadata in the glue code instead of the thread itself and prevents
the metadata from being released on exit of the uk thread. This way,
pthread_detach can detect that the thread has already been released.
Metadata is freed in pte_osThreadDelete (would have caused a double
free before the patch).

Signed-off-by: Marc Rittinghaus <marc.rittinghaus@kit.edu>
Reviewed-by: Vlad-Andrei <vlad_andrei.badoiu@upb.ro>
Approved-by: Simon Kuenzer <simon@unikraft.org>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #2

3 years agoMakefile.uk: Remove conflicting `sched_yield.c` from build process 5/head RELEASE-0.6 RELEASE-0.7.0
Sergiu Moga [Thu, 12 Aug 2021 11:54:50 +0000 (14:54 +0300)]
Makefile.uk: Remove conflicting `sched_yield.c` from build process

This commit removes the conflicting function definition for `sched_yield`
located inside the extracted `sched_yield.c` by removing the source file
from the build process.

Signed-off-by: Sergiu Moga <sergiu.moga@protonmail.com>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #1

4 years agoNo warning when assigning thread starters
Simon Kuenzer [Tue, 15 Dec 2020 08:19:13 +0000 (09:19 +0100)]
No warning when assigning thread starters

Suppresses a compiler warning that happens with code that assigns
thread starters.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Reviewed-by: Daniel Dinca <dincadaniel97@gmail.com>
4 years agoInitialize pthread-embedded as early as possible
Simon Kuenzer [Tue, 15 Dec 2020 08:19:12 +0000 (09:19 +0100)]
Initialize pthread-embedded as early as possible

Because other Unikraft libraries may create threads, we
initialize pthread-embedded within the early init class.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Reviewed-by: Daniel Dinca <dincadaniel97@gmail.com>
4 years agoRegister meta data on `uksched` thread creation callbacks
Simon Kuenzer [Tue, 15 Dec 2020 08:19:11 +0000 (09:19 +0100)]
Register meta data on `uksched` thread creation callbacks

Utilizes `uksched` callback mechanism to create and delete pthread-embedded
meta data for threads. This enables using pthread-embedded API calls on
threads that were created with the native `uksched` API.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Reviewed-by: Daniel Dinca <dincadaniel97@gmail.com>
4 years agolib/pthread-embedded: Support for uksignal RELEASE-0.5
Bernard Rizzo [Sat, 16 Jan 2021 01:52:32 +0000 (02:52 +0100)]
lib/pthread-embedded: Support for uksignal

This patch is an update of the original.

Signed-off-by: Mihai Pogonaru <pogonarumihai@gmail.com>
Signed-off-by: Teodora Serbanescu <teo.serbanescu16@gmail.com>
Signed-off-by: Felipe Huici <felipe.huici@neclab.eu>
Reviewed-by: ARGINT DRAGOS IULIAN <dragosargint21@gmail.com>
4 years agoInclude missing `<stdlib.h>`
Simon Kuenzer [Mon, 23 Nov 2020 13:03:47 +0000 (14:03 +0100)]
Include missing `<stdlib.h>`

The header `<stdlib.h>` provides definitions for
`malloc()`, `calloc()` and `free()`.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Reviewed-by: Razvan Deaconescu <razvan.deaconescu@cs.pub.ro>
4 years agoRemove compile warning
George Muraru [Wed, 22 Apr 2020 08:44:32 +0000 (11:44 +0300)]
Remove compile warning

Signed-off-by: George Muraru <murarugeorgec@gmail.com>
Reviewed-by: Hugo Lefeuvre <hugo.lefeuvre@neclab.eu>
5 years agoRemove reference to non-existing exportsyms.uk file .
Felipe Huici [Tue, 14 Apr 2020 15:17:49 +0000 (17:17 +0200)]
Remove reference to non-existing exportsyms.uk file .

This library used to have an exportsyms.uk file, but no longer
does. When it was removed, the reference to it in Makefile.uk was not
removed, leaving a dangling reference to a non-existing file. The
recent Unikraft build system series turned this into a build error, so
this patch fixes that by removing the line.

Signed-off-by: Felipe Huici <felipe.huici@neclab.eu>
Reviewed-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
5 years agoImplement pthread_condattr_{getclock, setclock}
Vlad-Andrei BĂDOIU [Tue, 31 Mar 2020 15:07:19 +0000 (18:07 +0300)]
Implement pthread_condattr_{getclock, setclock}

We adapt the implementation from musl.

Signed-off-by: Vlad-Andrei BĂDOIU <vlad_andrei.badoiu@stud.acs.upb.ro>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
5 years agoAdd clockid_t field to pthread_condattr_t_
Vlad-Andrei BĂDOIU [Tue, 31 Mar 2020 15:07:18 +0000 (18:07 +0300)]
Add clockid_t field to pthread_condattr_t_

Since pthread_condattr_t is defined as pthread_condattr_t_,
we add the clockid_t field to pthread_condattr_t_. This field
is used by funcions such as pthread_condattr_getclock.

Signed-off-by: Vlad-Andrei BĂDOIU <vlad_andrei.badoiu@stud.acs.upb.ro>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
5 years agoSupress warning to have a clean build. RELEASE-0.4
Felipe Huici [Wed, 12 Feb 2020 09:35:19 +0000 (10:35 +0100)]
Supress warning to have a clean build.

Signed-off-by: Felipe Huici <felipe.huici@neclab.eu>
Reviewed-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
5 years agoUse Unikraft initcall for initialization
Simon Kuenzer [Wed, 8 Jan 2020 09:14:50 +0000 (10:14 +0100)]
Use Unikraft initcall for initialization

Initialize the library by using an Unikraft initcall instead of the
constructor attribute. This is to make sure that pthread-embedded is
initialized before Unikraft calls any application constructors and
after Unikraft initialized the depending scheduler.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
5 years agoAdd pthread_condattr_{get, set}clock() stubs
Costin Lupu [Fri, 6 Dec 2019 13:12:31 +0000 (15:12 +0200)]
Add pthread_condattr_{get, set}clock() stubs

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@stud.acs.upb.ro>
5 years agoattributes.c: Allow GNU definitions regardless of _GNU_SOURCE
Costin Lupu [Fri, 6 Dec 2019 13:12:30 +0000 (15:12 +0200)]
attributes.c: Allow GNU definitions regardless of _GNU_SOURCE

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@stud.acs.upb.ro>
5 years agoRemove exportsyms.uk
Costin Lupu [Fri, 6 Dec 2019 13:12:29 +0000 (15:12 +0200)]
Remove exportsyms.uk

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@stud.acs.upb.ro>
5 years agoAdd != operator for pte_handle_t
Vlad-Andrei BĂDOIU (78692) [Sat, 9 Nov 2019 10:21:29 +0000 (10:21 +0000)]
Add != operator for pte_handle_t

Signed-off-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@stud.acs.upb.ro>
Reviewed-by: Costin Lupu <costin.lupu@cs.pub.ro>
5 years agoAdd pthread_sigmask() stub
Costin Lupu [Fri, 1 Nov 2019 11:20:01 +0000 (13:20 +0200)]
Add pthread_sigmask() stub

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Stefan Teodorescu <stefanl.teodorescu@gmail.com>
5 years agoSet priority to pthread constructor
Vlad-Andrei BĂDOIU (78692) [Wed, 30 Oct 2019 22:37:58 +0000 (22:37 +0000)]
Set priority to pthread constructor

Other libraries might use the default constructor attribute and expect pthreads
to be initialised. Currently, the priority for pthread-embedded library
constructor has the highest priority (101).

Signed-off-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@stud.acs.upb.ro>
Reviewed-by: Costin Lupu <costin.lupu@cs.pub.ro>
5 years agoAdd pte_{pop, push}_cleanup to exported symbols
Cyril Soldani [Tue, 15 Oct 2019 15:06:23 +0000 (17:06 +0200)]
Add pte_{pop, push}_cleanup to exported symbols

These functions are used by pthread_cleanup_{pop,push}.

Signed-off-by: Cyril Soldani <cyril.soldani@uliege.be>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
5 years agoSort exported symbols
Cyril Soldani [Tue, 15 Oct 2019 15:06:22 +0000 (17:06 +0200)]
Sort exported symbols

Signed-off-by: Cyril Soldani <cyril.soldani@uliege.be>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
5 years agoMakefile.uk: Rename SUPPRESS_FLAGS to LIBPTHREAD-EMBEDDED_SUPPRESS_FLAGS
Costin Lupu [Sat, 12 Oct 2019 12:33:26 +0000 (15:33 +0300)]
Makefile.uk: Rename SUPPRESS_FLAGS to LIBPTHREAD-EMBEDDED_SUPPRESS_FLAGS

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
5 years agopthread.h: Convert pthread_t to unsigned long
Costin Lupu [Sun, 13 Oct 2019 13:16:55 +0000 (16:16 +0300)]
pthread.h: Convert pthread_t to unsigned long

The POSIX standard outlines that pthread_t is an opaque data type and no
assumption should be made about it. However, we observed that libraries and
applications assume frequently that pthread_t is a pointer or other numerical
data type and use it to identify the corresponding threads.

pthread-embedded makes the strange decision to define pthread_t as
structure, a decision that, although compliant with POSIX standards,
makes the porting process a bit challenging. Therefore we introduce a
conversion function which simply returns the first encapsulated
unsigned long value in the structure which actually points to the
underlying thread object.

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
5 years agoAdd sched.h header
Costin Lupu [Wed, 21 Aug 2019 13:07:51 +0000 (16:07 +0300)]
Add sched.h header

Add it just to provide cpu_set_t type definition.

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
5 years agoExport semaphore symbols
Teodora Serbanescu [Tue, 30 Jul 2019 10:17:14 +0000 (13:17 +0300)]
Export semaphore symbols

Signed-off-by: Teodora Serbanescu <teo.serbanescu16@gmail.com>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
5 years agoAdd pthread_atfork() function
Costin Lupu [Tue, 9 Jul 2019 09:09:33 +0000 (12:09 +0300)]
Add pthread_atfork() function

For now, Unikraft does not support fork(), so we will just print an
warning saying that.

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
5 years agoMakefile.uk: Restrict pointer-to-int-cast and int-to-pointer-cast warnings only to C
Costin Lupu [Wed, 5 Jun 2019 08:01:20 +0000 (11:01 +0300)]
Makefile.uk: Restrict pointer-to-int-cast and int-to-pointer-cast warnings only to C

Otherwise we get warnings that these warnings are only C specific.

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
5 years agopatches: Add patch for making pte_handle a C++ structure
Costin Lupu [Wed, 5 Jun 2019 08:01:19 +0000 (11:01 +0300)]
patches: Add patch for making pte_handle a C++ structure

The CXX library requires pthe_handle to be defined as a C++ structure. This
patch also adds the overloaded operators needed by the CXX library.

Signed-off-by: Teodora Serbanescu <teo.serbanescu16@gmail.com>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
5 years agoinclude/pthread.h: Guard C code for C++
Teodora Serbanescu [Mon, 3 Jun 2019 15:16:40 +0000 (18:16 +0300)]
include/pthread.h: Guard C code for C++

Signed-off-by: Teodora Serbanescu <teo.serbanescu16@gmail.com>
Reviewed-by: Florian Schmidt <florian.schmidt@neclab.eu>
5 years agoAdd missing pthread functions
Costin Lupu [Mon, 3 Jun 2019 15:16:39 +0000 (18:16 +0300)]
Add missing pthread functions

This patch adds some missing functions for updating threads attributes,
such as the thread name or the stack address and size. Currently we
support only the fixed stack size of 64KB.

These new functions are used by the Ruby interpreter.

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Florian Schmidt <florian.schmidt@neclab.eu>
5 years agoDisable atomic functions
Costin Lupu [Mon, 3 Jun 2019 15:16:38 +0000 (18:16 +0300)]
Disable atomic functions

We disable the atomic function given that we are using them as macros.

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Florian Schmidt <florian.schmidt@neclab.eu>
5 years agopatches: Fix atomic operations
Costin Lupu [Mon, 3 Jun 2019 15:16:37 +0000 (18:16 +0300)]
patches: Fix atomic operations

We use atomic operations as macros because pte uses them for both int
and long types.

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Florian Schmidt <florian.schmidt@neclab.eu>
5 years agoInitial port of pthread-embedded to Unikraft
Costin Lupu [Mon, 3 Jun 2019 15:16:36 +0000 (18:16 +0300)]
Initial port of pthread-embedded to Unikraft

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 <costin.lupu@cs.pub.ro>
Reviewed-by: Florian Schmidt <florian.schmidt@neclab.eu>
5 years agopatches: Add patches for proper building of original library
Costin Lupu [Sun, 10 Mar 2019 08:12:24 +0000 (10:12 +0200)]
patches: Add patches for proper building of original library

Current patches include bugfixes and refinements in the original code.

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Florian Schmidt <florian.schmidt@neclab.eu>
5 years agoAdd .gitignore
Costin Lupu [Mon, 3 Jun 2019 15:16:34 +0000 (18:16 +0300)]
Add .gitignore

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Florian Schmidt <florian.schmidt@neclab.eu>
5 years agoAdd documentation
Costin Lupu [Mon, 3 Jun 2019 15:16:33 +0000 (18:16 +0300)]
Add documentation

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Florian Schmidt <florian.schmidt@neclab.eu>
6 years agoInitial commit (empty)
Costin Lupu [Sat, 9 Mar 2019 18:10:02 +0000 (20:10 +0200)]
Initial commit (empty)