https://github.com/malisha4065/pthreads
Pthreads tutorial
https://github.com/malisha4065/pthreads
c clanguage multithreading posix-threads pthreads
Last synced: about 1 year ago
JSON representation
Pthreads tutorial
- Host: GitHub
- URL: https://github.com/malisha4065/pthreads
- Owner: Malisha4065
- Created: 2025-03-27T18:09:25.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-27T18:22:07.000Z (over 1 year ago)
- Last Synced: 2025-03-27T19:30:37.089Z (over 1 year ago)
- Topics: c, clanguage, multithreading, posix-threads, pthreads
- Language: C
- Homepage:
- Size: 3.91 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Pthreads Examples
This repository contains various examples demonstrating the use of POSIX threads (pthreads) in C. Each file showcases a different aspect of multithreading.
## File Descriptions
- `main.c` - Basic thread creation using `pthread_create`.
- `hello_arg1.c` - Passing arguments to threads using an array.
- `hello_arg2.c` - Passing multiple arguments to threads using a `struct`.
- `hello_arg3.c` - Demonstrates incorrect argument passing (race condition example).
- `join.c` - Using `pthread_join` to wait for threads to complete.
- `stack.c` - Managing thread stack size with `pthread_attr_setstacksize`.
- `dotprod_serial.c` - Serial implementation of dot product calculation.
- `dotprod_mutex.c` - Parallel dot product calculation using mutex for synchronization.
- `condvar.c` - Demonstrates condition variables for thread synchronization.
## How to Compile and Run
To compile any of the C files:
```bash
gcc -pthread -o .c
```
To run the compiled program:
```bash
./
```