An open API service indexing awesome lists of open source software.

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

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
./
```