Filter
Exclude
Time range
-
Near
how am i just running across Linux's preadv2/pwritev2 just now? they seem to allow non-blocking disk i/o without pthreads via RWF_NOWAIT! manpages.debian.org/testing/…

1
6
581
Tu sais que c'est en gros pthreads légèrement repackagé 🤣
1
2
41
Advanced real-time operating system. PX5 RTOS from PX5, a member of the #STPartnerProgram, is based on industry-standard IEEE POSIX pthreads APIs and has a minimum memory footprint of 2 KB of Flash and 1 KB of RAM. 🔍 Learn more on the #STBlog: spkl.io/6013AAsdX
1
7
785
Apr 29
Replying to @raysan5
Just don't use MSVC. I know someone's going to say, "but you can't just not support MSVC!" I wouldn't be upset. You can. I've been MSVC free in everything I do now even on windows. It's great. I highly recommend it. MSYS2 is a better a development foundation on windows. RayLib works beautifully in the default UCRT64 setup and is a better default than what MSVC will give you. Lighter. Easier to install. Gives you more cross platform foundation out of the box (i.e. pthreads). You get the whole pacman manager in MSYS2 for easier setup of dependencies. An all MSYS2 centered workflow is great on windows. The only reason MSVC enters my mind anymore is that the linux gcc/clang support for a raddbg is stilll not shipped. Then you get to use GNU C and it's all the extra little things it comes with. Which GCC and Clang both support most of. MSVC is the oddball out at this point. I know some have an issue with that because, "It's not real C to spec!" I get that mentality if you are writing some ultra-portable library that needs to build on every archaic embedded device to ever exist. But GNU C is anchored in a stable constant with the Linux and BSD kernels and drivers themselves. The standard is being able to compile one of the kernels which everything, other than windows, runs on. To me that is more reassuring in long term stability than the written C spec being the forever source of truth. I'm perfectly Okay with being constrained to the compilers which can compile the kernels and drivers than enables me to even be able use the computer in the first place. I remember Linus had some rant about this long ago which is where the divergence to GNU C began. Basically saying if the language working a certain way, or having a certain feature, makes more sense for the pragmatic need of using that language to actually produce something valuable for the world. Then change or add that to the language. The purpose isn't adhering to some written document from decades ago. The purpose is doing something valuable. Personally, seeing how C spec standardization has gone I've come to believe it's the better way. Language standardization shouldn't be done through committee. It should be pragmatic based on real need in a real project. Every little feature and extension added to GNU C isn't from a whim of some researcher. Rather it's done in response to a real pragmatic need in kernel development.
2
6
2,150
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. en.wikipedia.org/wiki/Distri…
1
2
497
Replying to @BenjDicken
Yes. # *IMPORTANT* Always use pthreads.
4
279
Replying to @JuhoMuhonen
Does it come with pthreads?
1
2
6,353
SpectraFlux is a native macOS SDR spectrum analyzer with Metal GPU rendering and vDSP FFT in Swift. All running on an entry-level Mac Mini M4 driving a 4K display. Here's where things stand: Hardware support: USRP B210 (just added — runtime library loading, works without UHD installed), PlutoSDR, RFSPACE NetSDR (including dual-channel X2 board), CloudIQ, CloudSDR, Nixara FPGA SDR, SDRanywhere thin client. Plus VRT (VITA 49.0) generic receiver. All through a unified lock-free SPSC ring buffer with gap-aware FFT processing. Demod: Full AM/USB/LSB/NFM/WFM/CW/SAM demod chain. Works at sample rates up to 125 MS/s — cascaded half-band decimation down to audio. RDS decode in WFM mode (BPSK PLL, differential decode, Meggitt FEC, PI/callsign/PS/RadioText). AGC with look-ahead delay line. Noise reduction — two engines: LMS adaptive filter (variable-leak, 64 taps) for narrowband modes Spectral NR2. Doppler correction: Consumer-side NCO with per-sample frequency interpolation. Supports frequency rate (quadratic phase accumulation for linear chirps). Phase-coherent across all 4 channels in multi-antenna mode. Rigctld server for satellite tracking integration. Recording: WAV, SigMF (ci16_le JSON metadata with geolocation), raw .cs16, RF64 (>4 GB), R&S .wv. Spectrogram formats: strf .bin (Cees Bassa format for rfplot satellite Doppler analysis) and SIGPROC .fil (PRESTO/HEIMDALL radio astronomy). Gapless segmented recording. Full IQ playback for all formats. Networking: VRT IQ forwarding to external tools (4 modes — CS16/CF32 × standard/jumbo frames). Built-in web remote with spectrum waterfall audio over WebSocket (U8 spectrum, µ-law/G726 audio, ~15 KB/s to a phone). Rigctld server compatible with WSJT-X and GPredict. ADS-B: Mode S decoder, sample-rate-aware (works at 2-20 MS/s with PlutoSDR,NetSDR , B210 at 1090 MHz). Beast TCP server on port 30005 — feed straight to tar1090 for a map display. FMCW radar: Chirp dechirper with matched-filter cross-correlation and range-time intensity waterfall. Slope measurement via spectrogram linear regression. Pulling 42 dB SNR off CODAR oceanographic HF radars at 4-5 MHz. Multi-antenna imaging: Nixara 4-channel coherent mode — 4 synchronized IQ streams at 62.5 MS/s each (250 MS/s aggregate) over 10GbE, zero drops, on the entry-level M4. VRT timestamp alignment, cross-correlation on all 6 baselines, 128×128 UV grid, 2D inverse FFT for all-sky dirty beam synthesis. Road map: 5× four-channel Nixara SDRs for a 20-element interferometric array — 190 baselines, real-time UV imaging. Display: Metal compute shaders, digital phosphor persistence with configurable decay (OFF through CRT mode), 21 colormaps including P1/P12/P7 phosphor emulations. HP 8568B-style marker system with 4 markers, delta mode, peak search. 8 trace overlays (peak hold, min hold, 3 averaging speeds, decay modes). 10 FFT window functions. Cursor readout. Click-to-tune. Aux displays: Audio scope, IQ scatter plot, audio waterfall, continuum strip chart — all colormap-colored. Native Apple Silicon. Metal for rendering, vDSP/Accelerate for DSP, pthreads for real-time receiver threads. 日本のSDRユーザーの皆さんへ: SpectraFluxはApple Silicon Mac向けのネイティブSDRスペクトラムアナライザーです。Metal GPUレンダリング、リアルタイム復調、デジタル蛍光体表示、衛星追尾用ドップラー補正、4チャンネルコヒーレントアレイによる電波イメージングなど、本格的な無線研究ツールを目指しています。興味のある方はぜひフォローしてください。開発の最新情報をお届けします。
5
18
138
8,751
Learn about pthreads, seriously!
4
3
118
7,633
built a simplified @solana turbine shredding protocol in c. splits transactions into data and coding shreds using reed-solomon via a custom cpp wrapper around the leopard library, validates in parallel via a custom pthreads pool, and recovers lost shreds. tested on 10k @solana mainnet txs pulled straight from mainnet using a bash script. 10,000/10,000 recovered.
9
7
145
6,371
Replying to @dmitriid
There are no locks, and thread death raises a signal and is handled by the language and runtime’s standard error handling mechanisms (which may or may not include terminating the process). You act like we’re using pthreads. This hasn’t been true for decades.
2
16
2,982
Some people have asked me how i did the Umineko web assembly, some asked me to write about how i achieved it. I said i would when it was functinally complete, so here is the deep technical dive. Please enjoy This is he full PS3/Umineko Project build running as WebAssembly in a tab. Here is how I did it and why it was painful. The game runs on ONScripter-RU, a C 14 visual novel engine originally built for Windows, macOS, Linux, iOS, and Android. It was never designed for the browser. It depends on multithreading, synchronous file I/O, GPU rendering, and over a dozen native C/C libraries. The codebase is, to put it lightly, is a absolute cluster-fuck Barely any documentation, deeply coupled components, and architectural decisions that seem designed to make porting as difficult as possible. I had to modify 18 source files across the engine just for the Emscripten target, all gated behind # ifdef __EMSCRIPTEN__ so the native builds still work. The tool that makes this possible is Emscripten, a compiler toolchain that takes C/C and outputs WebAssembly. It provides drop-in replacements for gcc/g (emcc/em ) and ships with browser-compatible ports of common libraries like SDL2, FreeType, zlib, libpng, and libvorbis. But not everything the engine needs has a port. FFmpeg, SDL2_gpu, libass, HarfBuzz, and FriBidi all had to be cross-compiled from source using emconfigure and emmake. Each one came with its own set of build issues. The first major problem was threading. ONScripter-RU uses threads everywhere. Video decoding has a demuxer thread, a video decoder thread, and an audio decoder thread all communicating through semaphore-gated packet queues. Subtitle rendering runs on its own background thread. File loading happens off the main thread. Emscripten technically supports pthreads via SharedArrayBuffer, but that requires specific COOP/COEP headers, has browser compatibility issues, and the engine's threading model is deeply embedded in its architecture in ways that do not translate cleanly. I went the other route, single-threaded synchronous execution using Emscripten's ASYNCIFY transform. ASYNCIFY rewrites the compiled code so that synchronous C functions can yield to the browser's event loop and resume later. The engine's main loop calls emscripten_sleep() to yield, so the browser tab does not freeze. But every subsystem that relied on threads had to be rewritten. For video playback, I wrote pumpSynchronous() - a function that replaces the entire multi-threaded decode pipeline. Instead of three threads communicating through queues, a single function call reads packets from the container with av_read_frame(), routes them to the appropriate decoder, converts video frames from YUV to RGB, and pushes finished frames into a bounded queue. The queue is capped at 6 frames because at 1080p RGB24, each frame is roughly 6MB, and WebAssembly has a 2GB memory ceiling. Overflow means OOM and a dead tab. For file I/O, the challenge was different. Umineko has over 101,000 game files. Backgrounds, sprites, character portraits, audio tracks, video files, subtitle files. Loading all of them at startup would mean downloading gigabytes before the game even starts. The solution was a lazy loading virtual filesystem. At container startup, a script walks the game directory and generates a manifest.json listing every file. When the browser loads the page, it creates the full directory tree in Emscripten's virtual filesystem and writes 0-byte stubs for every asset. Critical files like the game scripts, fonts, and configuration are fetched eagerly before main() runs. Everything else stays as a stub. When the engine opens a file, a patched FileIO::openFile() checks if it is a 0-byte stub. If it is, it calls an EM_ASYNC_JS function that does an await fetch() to download the real file over HTTP, writes the contents into the virtual filesystem, and then returns the file handle to the C code. From the engine's perspective, it called fopen() and got a file. It has no idea an HTTP request happened in between. The game starts in seconds, downloading only about 2MB of essential data, with everything else streaming in on demand as you play. The graphics pipeline was more straightforward but still required work. ONScripter-RU uses SDL2_gpu with a GLES2 backend. On native platforms this talks to OpenGL ES. In Emscripten, SDL2 creates a canvas element and binds a WebGL context. The engine renders everything as GPU textures via GLSL shaders. One thing that tripped me up was WebGL's default behaviour of clearing the drawing buffer between frames. The engine uses a partial-redraw dirty rect system that assumes the previous frame's pixels are still there. I had to enable preserveDrawingBuffer on the WebGL context to stop it from wiping the canvas every frame. Audio was one of the easier pieces. SDL2_mixer feeds into Emscripten's SDL2 audio backend, which routes to the Web Audio API. BGM, sound effects, and voice lines all work through this path. The output is 48kHz 32-bit float stereo. The browser handles the rest. The subtitle system was one of the more frustrating challenges. Umineko's video cutscenes have song lyrics displayed as timed .ass subtitles (Italian original English translation). This requires a full text shaping and rendering stack: libass for parsing and rendering ASS subtitles, HarfBuzz for complex text shaping, FriBidi for Unicode bidirectional text, and FreeType for font rasterisation. libass and FriBidi compiled without too much trouble once I patched out iconv detection in libass's configure script (Emscripten does not have iconv). HarfBuzz 2.5.2 was a different story. It uses # pragma GCC diagnostic error in its main header file (hb.hh) to promote specific compiler warnings to hard errors. Clang 18, which ships with Emscripten 3.1.51, introduced a new warning called -Wcast-function-type-strict. HarfBuzz's own code triggers this warning in several places, and the pragma turns it into an error. The fix is not in any Makefile or configure script. It is a source-level pragma that overrides anything you pass on the command line. I went through about 10 different approaches before finding that HarfBuzz has an internal kill switch macro: -DHB_NO_PRAGMA_GCC_DIAGNOSTIC_ERROR. Adding that to the build flags disables all the diagnostic error pragmas and lets it compile cleanly. Once the subtitle libraries were built, the rendering itself needed work. The native engine decodes subtitles on a background thread that feeds frames into a queue. On Emscripten, that thread never starts because there are no threads. I had to add subtitle blending directly into the synchronous video decode path. After each video frame is decoded and colour-converted, but before it enters the frame queue, libass renders the subtitle overlay for that frame's timestamp and blends it onto the pixel data. The subtitle rendering that normally happens across two threads now happens inline in a single function. The save system uses Emscripten's IDBFS driver. At startup, /home/web_user/.onscripter is mounted as an IDBFS volume and synced from IndexedDB. The engine reads and writes save files using normal C file operations, completely unaware that the underlying storage is a browser database. A periodic sync runs every 5 seconds, and a beforeunload handler flushes on tab close. Save data survives page refreshes, tab closures, and browser restarts. The Docker build puts this all together. A multi-stage Dockerfile starts from emscripten/emsdk:3.1.51, cross-compiles all six native libraries (SDL2_gpu, FFmpeg 3.3.9, FriBidi 1.0.5, HarfBuzz 2.5.2, libass 0.14.0), clones the forked engine, embeds GLSL shaders into a C source file, compiles 60 source files into a single WASM binary, and packages everything into an nginx:alpine image that serves the game. The final output is three files: an HTML shell, a JavaScript loader, and the WASM binary. The game is fully playable. Script execution, text rendering, image display, visual effects, video cutscenes with subtitles, audio, save/load, settings; everything works. The entire thing runs client-side in a browser tab.
11
27
231
9,349
Currently building a demo version of a protocol which practices random linear network coding (rlnc) the file is broken into blocks, but Peer A doesn't send "block 1" to Peer B. Instead it generates a random linear combination of blocks it has and sends that single packet along with coefficients used another interesting thing which happens is the receiver doesn't need specific block you sent, they need enough so called "equations" to solve the matrix and reconstruct the original file tech stack got now C, Makefile, POSIX sockets, pthreads, Custom GF(2^8) math module
4
2
126
6,597
Replying to @coffnix
Pois é. Geralmente esses fatalistas nunca escreveram nada que roda em produção por um bom tempo. Um fdp desses nunca escreveu um server usando pthreads, sinais e usou o Valgrind pra debugar. Esse giroto mesmo deve entender de pau de cavalo 🤣🤣🤣🤣🤣
3
6
426
Implementing Threads in C: Designing Concurrent Programs with pthreads
1
4
91
3,384
Replying to @loganb @moultano
We found a bug in glibc's pthreads implementation. It was a bit scary to realize we were the first Bug#266507: NPTL (0.60) quirks with pthread_create (ignores attributes) share.google/RGhRTqNVQwA0AJA…

6
86
Jan 20
Well, I wrote small lisp interpreter with pthreads and since then I have these particular opinions on dynamic language implementations with GIL (not neccessary) and fine-grained locking overhead (will bite you in the ass).
4
29
I keenly remember one Lisper who wrote a small Lisp interpreter that had pthreads, and loudly proclaimed "we now have a parallel symbolic homoiconic language" (conveniently ignoring literally everything, including interesting historical artifacts like *Lisp by Hillis et al.).
3
1
9
385