Skip to content

A user-level thread library implementation for the Nanvix Educational OS.

License

Notifications You must be signed in to change notification settings

Bois-Barganhados-Studio/nanvix-user-level-thread

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bthread - A basic user-level thread library for Nanvix

The Bthread library was created for the Interdisciplinary Project V subject of the computer science course at PUC Minas with educational purposes in mind, such as, helping students understand how concurrent programs work as well as providing ways for the developing of concurrent programming practices.

About Bthread

Features

The Bthread library implements a preemptive aproach with round-robin and provides the following features: Thread creation and termination

  • Thread joining and detaching
  • Thread cancellation
  • Thread yield
  • Mutexes

API

The Bthread library API is composed of the following functions:

int bthread_create(bthread_t *thread, void *(*start_routine)(), void *arg);
int bthread_join(bthread_t thread, void **thread_return);
int bthread_detach(bthread_t thread);
void bthread_yield(void);
bthread_t bthread_self(void);
int bthread_cancel(bthread_t thread);
struct bt_mutex *bthread_mutex_init(void);
int bthread_mutex_lock(struct bt_mutex *mutex);
int bthread_mutex_unlock(struct bt_mutex *mutex);
int bthread_mutex_destroy(struct bt_mutex *mutex);

For more information about the Bthread library API, please refer to the bthread.h header file.

Usage

To use the Bthread library in a Nanvix program, the following steps must be taken:

  1. Setup the Nanvix development environment as described at setup.md.
  2. Create a new user program in the src/ubin directory.
  3. Include the bthread.h header file in the user program.
  4. Build Nanvix as described at build.md.
  5. Run Nanvix using your choosen system simulator (QEMU is recommended).

Example

A simple example of the Bthread library usage is available in the user program bthd in Nanvix, its source code is available at src/ubin/bthd/bthd.c.

About Nanvix

What Is Nanvix?

Nanvix is a Unix-like operating system written by Pedro Henrique Penna for educational purposes. It is designed to be simple and small, but also modern and fully featured.

What Hardware Is Required to Run Nanvix?

Nanvix targets 32-bit x86-based PCs and only requires a floppy or CD-ROM drive and 16 MB of RAM. You can run it either in a real PC or in a virtual machine, using a system image.

License and Maintainers

Nanvix is a free software that is under the GPL V3 license and is maintained by Pedro Henrique Penna. Any questions or suggestions send him an email: [email protected]

BThread

BThread is also under the GPL V3 license and was made by:

Releases

No releases published

Packages

No packages published

Languages

  • C 93.7%
  • Assembly 2.7%
  • Shell 1.9%
  • Makefile 1.7%