A multi-threading library for C Programs
Table of Contents
About The Project
CthreAd is a multi-threading library which implements POSIX compliant threads in the Linux userland. Primarily, we have implemented two models of multi-threading:
One-One model of multi-threading maps each user-level thread with a kernel-level thread. All the threads can access the kernel at the same time. Even if a thread makes a blocking system call (i/o, etc.), other threads can continue to run.
The many to one model maps many of the user threads to a single kernel thread. This model is quite efficient as the user space manages the thread management. The library performs the context-switch and scheduling operations.
To use CthreAd in your projects:
- Clone the repository using
$ git clone https://gitlab.com/andipro123/cthread.git
- Move to the directory and choose the model you want to implement
# for one-one $ cd cthread/one-one # for many-one $ cd cthread/many-one
- Compile the library
$ gcc cthread.c -c -Wall #for many-one, use "cthread2.c"
- Include the header file in your project
// Your C program #include<cthread.h> . . .
- Compile your project using
$ gcc <your-project.c> cthread.o - o <your-project> #for many-one, use "cthread2.o"
The library comes with an automatic testing package to test all the functionalities of the threading library. Tests cover all areas of multi-threading to ensure that basic functions are working as expected. To run the tests:
$ make run
This library is not a production level multi-threading library yet. Please use caution while using it in your production softwares. Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature)
- Commit your Changes (
git commit -m 'Add some AmazingFeature')
- Push to the Branch (
git push origin feature/AmazingFeature)
- Open a Pull Request