<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Concurrency on Blog</title><link>https://blog.hoshiyomi-dev.work/tags/concurrency/</link><description>Recent content in Concurrency on Blog</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Sun, 11 Oct 2026 10:54:05 +0000</lastBuildDate><atom:link href="https://blog.hoshiyomi-dev.work/tags/concurrency/index.xml" rel="self" type="application/rss+xml"/><item><title>Kcalc Self Deadlock</title><link>https://blog.hoshiyomi-dev.work/post/kcalc-self-deadlock/</link><pubDate>Sat, 22 Aug 2026 02:45:35 +0800</pubDate><guid>https://blog.hoshiyomi-dev.work/post/kcalc-self-deadlock/</guid><description>&lt;h2 id="context"&gt;Context&lt;/h2&gt;
&lt;p&gt;&lt;a href="https://github.com/xDDoubleTea/kcalc"&gt;kcalc&lt;/a&gt; is a calculator running directly in kernelspace.
Achieved by loading as a Linux kernel module, and by exposing a character device &lt;code&gt;/dev/kcalc_chardev&lt;/code&gt; to the userspace, supporting
&lt;code&gt;read, write&lt;/code&gt; operations.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;A process &lt;code&gt;write&lt;/code&gt; the expression they want to evaluate to &lt;code&gt;/dev/kcalc_chardev&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;That process then &lt;code&gt;read&lt;/code&gt; from &lt;code&gt;/dev/kcalc_chardev&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;The character device is locked whenever a process is writing to/reading from it via &lt;code&gt;mutex_lock();&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;The kernel is tested using &lt;code&gt;pytest&lt;/code&gt;, calls &lt;code&gt;tee&lt;/code&gt; and &lt;code&gt;cat&lt;/code&gt; for &lt;code&gt;write&lt;/code&gt; and &lt;code&gt;read&lt;/code&gt; operations respectively&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="what-happened"&gt;What Happened&lt;/h2&gt;
&lt;p&gt;When running the &lt;code&gt;pytest&lt;/code&gt; suite, the process hangs indefinitely, no cases is passed or failed. It is also unkillable. Opening &lt;code&gt;btop&lt;/code&gt; reveals that the &lt;code&gt;cat&lt;/code&gt; process is there hanging, and causing the &lt;code&gt;pytest&lt;/code&gt; which calls &lt;code&gt;cat&lt;/code&gt; as a subprocess hangs. The &lt;code&gt;cat&lt;/code&gt; process is unkillable even with &lt;code&gt;SIGKILL&lt;/code&gt;.&lt;/p&gt;</description></item></channel></rss>