Top Tweets for #pthread
My advising supervisor did their dissertation on this 20 years ago and networks have got fast enough to make it feasible. Glad its making a comeback
Distributed shared memory: tldr, think std::threads or pthreads having access to memory locally but also on multiple machines.
https://t.co/NSp2xqP8om
I wrote a thread pool library in C and experimented with it to concurrently run the recursive calls of quicksort algorithm.
Find the project and details here:
https://t.co/g4aEa9av7u
#systemsprogramming #linux #concurrency #multithreading #lowlevel #Cprogramming #pthread
The most common examples for parallelism and concurrency
include using Pthread in C and Goroutine in Golang, As Pthread gives real OS thread which gives true parallelism on the other hand Golang allows u to create multiple threads which are virtual and then context switching between them
However let me tell one interesting thing to you ppl that context switching is expensive but threads are limited
So it's always a tradeoff, either I u can have a cpu with hundreds of cores to support hundreds of threads or you can have less core but context switching between thread
So most of the language choose concurrency over true parallelism
Though they can do parallelism during runtime if there's enough core for the fired thread
The most common examples include using Pthread in C and Goroutine in Golang, As Pthread gives real OS thread which gives true parallelism on the other hand Golang allows u to create multiple threads which are virtual and then context switching between them
However let me tell one interesting thing to you ppl that context switching is expensive but threads are limited
So it's always a tradeoff, either I u can have a cpu with hundreds of cores to support hundreds of threads or you can have less core but context switching between thread
So most of the language choose concurrency over true parallelism
Though they can do parallelism during runtime if there's enough core for the fired thread
Build a minimalist multi-threaded FTP server in C
- learn socket programming fundamentals
- handle concurrent file transfers with pthreads
- implement basic file serving with sendfile()
perfect for understanding how network file transfers work under the hood!

How to start with low-level programming, at least how I started
Basic roadmap and resources (link in comments)
1. Start with C language
- Cover all basics to advanced topics like pointers, memory allocation, File I/O
- Basic data structures: arrays, linked lists, and trees
2. Learn about sockets, TCP/UDP
- Build a few projects like a basic TCP server in C, HTTP server in C, real-time chat between server and client in C
- Learn more advanced topics like hashing, enum, etc.
3. Learn basic libraries like libcurl and SDL (if you wish to explore the graphics part)
4. Learn operating system basics
- What is an OS? How does a bootloader work?
- What is privileged and unprivileged mode?
- What is kernel, driver, and module?
5. Switch from Windows to any Linux distro (recommended: Ubuntu)
- Learn Linux basic commands
- Learn folder tree architecture basics in Linux
- Learn how to make system calls inside it
- Learn about pthread, fork, and process management
- Write some of the Linux commands yourself, for instance your own cat and ls in C
- Create your own module and driver for hardware
- Explore linux documentation
- Also create a module which can talk to userspace programs
6. Learn assembly for any architecture you wish
Recommendation: go with x86-64 (widely available, easy to learn and find resources)
- Build small programs using functions, records, files, etc. in assembly
- Work with file handling in assembly
- Build basic GUI program using GNOME API calls
7. Build some advanced projects
Though you need to study more core theory, as far as language goes you're all set
- Real-time web chat with server written in C
- Basic compiler design
- Basic database architecture
- Your own web/file protocol
- Basic JavaScript engine
- Build your own small bootloader in assembly
Now you can choose any specific field like hardware and IoT, kernel development, compiler design, protocol design, etc.
In a basic futex mutex (like the simple C implementation), if the holding thread crashes without unlocking, the mutex stays locked in userspace memory. Waiters remain blocked, leading to potential deadlock, as the kernel doesn't automatically release it.
For robustness, use pthread_mutex with PTHREAD_MUTEX_ROBUST attribute or implement robust futexes, where the kernel detects owner death and sets FUTEX_OWNER_DIED, allowing recovery.
Build a minimalist multi-threaded FTP server in C
- learn socket programming fundamentals
- handle concurrent file transfers with pthreads
- implement basic file serving with sendfile()
perfect for understanding how network file transfers work under the hood!

2. Project basics / files
You only need:
- mongoose.h (and mongoose.c if using the standalone source)
- server.c your app
Example compile:
gcc -O2 -o server server.c mongoose.c -pthread
A Detailed Explanation of CUDA Thread Hierarchy
(Threads, Blocks, and Grids):
A CUDA thread is the smallest unit of execution on the GPU, similar to a CPU thread, but designed for massive parallelism, each thread has its own registers and runs the same kernel code independently, operating on different pieces of data following the SIMT – Single Instruction, Multiple Threads model.
Thousands of threads can execute simultaneously, and the GPU groups them into warps of 32 threads for efficient scheduling and execution.
both SASS (lowest level, hardware specific assembly language for NVIDIA GPUs) and PTX (parallel thread execution) programs target threads. Compare this to a typical C program in a POSIX environment, which targets a process, itself a collection of one or more threads.
what exactly does this mean?
PTX and SASS are per-thread programs, means when you write a CUDA kernel, its complied into code that runs individually for each CUDA thread. EVery thread runs its own copy of that code with its own registers and local variables.
now, a C program on linux targets a process, which can contain one or more POSIX threads (or pthread, standard way of creating and managing threads on linux and macos). Those threads share memory and can make system calls, CUDA threads however, are very different, they run on the GPU, not the CPU and cannot make syscalls.
A Thread Block is a group of threads that execute together on a single streaming multiprocessor (SM). threads within a block can communicate and share data through shared memory, which is much faster than global memory. each thread in the block has a unique thread index, allowing it to operate on a specific piece of data. thread blocks are limited in size (usually up to 1024 threads per block) and are the basic unit that the GPU schedules onto an SM.
thread blocks are mostly independent units of computation. they can execute concurrently, but the exact order isnt guaranteed. on a GPU with a single SM, they may run one after another, while on GPU with enough resources, multiple blocks can run fully in parallel. the memory that all blocks can access, regardless of which SM they’re on, is the global memory.
now, thread blocks are organized into a grid, which can be one, two, or three-dimensional depending on the data being processed. the size of the grid is usually determined by the total amount of work, which often exceeds the number of available SMs. each block in the grid has a unique index (blockIdx) and knows its size (blockDim), allowing threads within the block to calculate their global position in the overall data. the number of threads per block and blocks per grid can be specified using either int or dim3, making it easy to map multidimensional data like images or matrices onto the GPU.
grids let the GPU manage thousands or even millions of threads efficiently by distributing blocks across available SMs, forming the backbone of large scale parallel execution.
thread blocks can also be grouped into clusters to improve execution efficiency and memory access patterns. clusters allow the GPU to schedule multiple blocks together on the same SM, making better use of shared memory and caches. by organizing threads hierarchically, from threads to blocks to grids to clusters, programmers can scale their code to millions of threads while maintaining high parallel efficiency and low memory latency.

@Sigmabond01 i saw a little bit of mutex in there in the image, are you also reading concurrency using pthread?
@zuhaitz_dev Please the threads.h header and not pthread.h!
Stack memory is allocated at program start time.
If you exceed the stack memory capacity (when running pthreads for ex.) it triggers a page fault, increase in stack size and continued program execution - and depending on the size of the local cache that physical memory may reside in the cache or in the main memory. Exactly where between the two depends on the "cache demand" on that core from various other processes, programs etc.,
Heap memory is allocated at program run time.
If the size of heap is such that the CPU can fit in the local cache, it it will do so. But the generally implicit reason for using heap is demand for memory capacity which exceeds local cache size.
My point is, its generally not worth the headache to force leak stack memory.
Built a multi-threaded TCP echo server in C and used standard libraries like sys/socket.h, pthread.h for threading, and signal.h for shutdown handling.

@Feoramund Well, sure, if you're on a platform not supported by pthreads or similar, you're going to need to reimplement pretty much everything, from thread spawning/joining to putting them to sleep on a mutex and waking them up.
I upgraded my HTTP/1.1 server in C with POSIX sockets, a pthreads thread pool, for logging, and select for keep-alive, adding header parsing, chunked file transfers, directory listings, HEAD/OPTIONS support, port/root configuration, timestamped logs, Date/Server/Last Modified headers, signal handling, expanded MIME types, and path security
Now it serves static files (HTML, CSS, JS, images, PDFs), lists directories, handles concurrent GET/HEAD/POST/OPTIONS requests, and supports persistent connections.

I built a professional, multi-threaded HTTP/1.1 server in C using POSIX sockets and pthreads, capable of handling concurrent GET and POST requests, parsing methods/paths/headers, serving static files from a root directory with MIME type detection, basic security against path traversal, error responses (200/400/403/404/405/500), and running on port 8080.
compile with gcc http_server.c -o http_server -lpthread and test via browser or curl for a robust foundation you can extend!

I built a professional, multi-threaded HTTP/1.1 server in C using POSIX sockets and pthreads, capable of handling concurrent GET and POST requests, parsing methods/paths/headers, serving static files from a root directory with MIME type detection, basic security against path traversal, error responses (200/400/403/404/405/500), and running on port 8080.
compile with gcc http_server.c -o http_server -lpthread and test via browser or curl for a robust foundation you can extend!

Last Seen Hashtags on Sotwe
Trends for you
Most Popular Users

Elon Musk 
@elonmusk
239.7M followers

Barack Obama 
@barackobama
118.6M followers

Cristiano Ronaldo 
@cristiano
114.3M followers

Donald J. Trump 
@realdonaldtrump
111.7M followers

Narendra Modi 
@narendramodi
106.9M followers

Rihanna 
@rihanna
98.6M followers

NASA 
@nasa
92.1M followers

Justin Bieber 
@justinbieber
91.7M followers

KATY PERRY 
@katyperry
89.9M followers

Taylor Swift 
@taylorswift13
83.9M followers

Lady Gaga 
@ladygaga
75.4M followers

Virat Kohli 
@imvkohli
73.3M followers

Kim Kardashian 
@kimkardashian
70.8M followers

YouTube 
@youtube
68.6M followers

Neymar Jr 
@neymarjr
66.3M followers

Bill Gates 
@billgates
65.1M followers

Selena Gomez 
@selenagomez
63M followers

The Ellen Show
@theellenshow
62.1M followers

CNN 
@cnn
61.7M followers

X 
@x
60.6M followers















