Linux 的 RT (Real-Time) 版本 PREEMPT_RT

Hacker News Daily 上看到的,Linux kernelPREEMPT_RT 這個 RT patch 併入 official repository 了:「Real-time Linux is officially part of the kernel after decades of debate」。

這類需求可以在 RTOS 裡面看到完整的說明,大家常用的特性是確保反應時間這點,像是對汽車自動駕駛的操作。

從 Linux 開始流行後就有人會想要這個需求了,而 open-source software 當然就會有人實作,不過一直是以 out-of-tree patch 的形式在維護。

其他在市場上常見的選擇有 VxWorks 以及 QNX,以前就蠻常聽到這些 OS 的應用。

另外翻資料時發現 Windows CE 也有做到即時性,不過微軟已經淡出這塊市場,Windows CE 2013 的支援到去年的 2023/10/10,但比較特別的是居然還有在賣,預定賣到 2028 年:(下面這段出自 CE migration - Frequently Asked Questions)

While Windows CE 2013 will reach end of extended support in late 2023, Microsoft will allow license sales to continue for Windows Embedded Compact 2013 until 2028. And of course, Windows CE devices can continue to be used indefinitely.

然後已經掛掉的 Symbian 也有做到即時性。

回到 Linux 這邊的情況,其實讓我比較驚訝 (但想了一下覺得好像也合理) 的是 printk 原來是個阻礙:

Torvalds wrote the original code for printk, a debugging tool that can pinpoint exact moments where a process crashes, but also introduces latency that runs counter to real-time computing.

在「[PATCH printk v5 0/8] provide nbcon base」有提到是 atomic 需求,為了解決這個問題設計了 NBCON (non-blocking console):

This is v5 of a series to introduce the new non-BKL (nbcon) consoles. v4 is here [0]. For information about the motivation of the atomic consoles, please read the cover letter of v1 [1].

「用正確的方法解決」的堅持,看起來陸陸續續在收尾階段了。

即時將動畫 Upscale 到 4K 畫質的演算法

看到「Anime4K」這個專案:

Anime4K is a state-of-the-art*, open-source, high-quality real-time anime upscaling algorithm that can be implemented in any programming language.

State of the art* as of August 2019 in the real time anime upscaling category, the fastest at acheiving reasonable quality. We do not claim this is a superior quality general purpose SISR algorithm compared to machine learning approaches.

他們提供的數據顯示 1080p -> 2160p (4K) 只要 3ms,對於 60fps 來說是相當足夠,而品質看起來也還不錯。

其中一個蠻有趣的問答是 1080p -> 2160p 反而比 480p -> 720p 簡單,因為 1080p 裡面因為有更多資料量,所以處理起來比較簡單:

Why not do PSNR/SSIM on 480p->720p upscaling
Story Time

Comparing PSNR/SSIM on 480p->720p upscales does not prove and is not a good indicator of 1080p->2160p upscaling quality. (Eg. poor performance of waifu2x on 1080p anime) 480p anime images have a lot of high frequency information (lines might be thinner than 1 pixel), while 1080p anime images have a lot of redundant information. 1080p->2160p upscaling on anime is thus objectively easier than 480p->720p.