Fact 0
:::info
:bulb: Calling pthread_exit on main thread may block when the jobs executed by other threads do not complete
:::
#include <pthread.h>
#include <stdio.h>
#include <unistd.h>
void *looping(void *args)
Oscar Shiang changed a year agoView mode Like Bookmark
To help us disect the problem from a deployed binary, it will be useful to build some information like git-commit hash, build date, etc.
Use vergen to generate a list of env during building.
You have to add vergen into Cargo.toml.
[package]
build = "build.rs"
[build-dependencies]
Oscar Shiang changed 2 years agoView mode Like Bookmark
:::info
:pencil: 這篇筆記是從 The Linux Foundation 的 Webinar "Setting Up an Environment for Writing Linux Kernel Modules in Rust" 整理而來,有興趣的可以觀看錄影存檔
:movie_camera: Setting Up an Environment for Writing Linux Kernel Modules in Rust [color=#33b2ff]
:::
:::success
:bulb: 在本篇筆記的命令列範例中,若前綴為 $ 者,表示其執行在 host 端;而前綴為 # 者,表示其須執行在 guest 端
:::
Oscar Shiang changed 3 years agoView mode Like 4 Bookmark
contributed by < OscarShiang >
:::success
:pencil: The implementation is in OscarShiang/FreeRTOS-Briey
:::
Briey SoC
VexRiscv is a risc-v hardware implementation written by SpinalHDL. This implementation not only provides the basic extension like [I] and [M] but also other plugins like CSR plugin for previledged registers and instructions to do switching between machine mode and user mode.
Briey SoC is a basic implementation based on VexRiscv. It has the following peripherals to use:
Oscar Shiang changed 3 years agoView mode Like 1 Bookmark
contributed by <OscarShiang >
Port count_bits into srv32
Because we now move our code from Ripes to bare metal environment, we need to follow the calling convention carefully.
Thus we should ensure that all we use saved registers and temporary registers properly.
:::info
:pencil: The revised code can be found at 6cc195f
:::
Oscar Shiang changed 3 years agoView mode Like Bookmark
To run BK on Raspberry Pi, we need several steps to set up your hardware
Pre-requisites
Raspberry Pi 4
TTL to USB cable
micro SD card
USB type A to type C cable (or power cable)
Format SD card
Oscar Shiang changed 3 years agoView mode Like Bookmark
contributed by < OscarShiang >
Rewrite Sqrt(x)
I implement my code based on 李政憲's one. Because I am curious about the way to compute the square root of a number without using brute force.
I have rewritten the code to find floor(sqrt(x)) with binary search approach.
#include <stdint.h>
#include "math.h"
Oscar Shiang changed 3 years agoView mode Like Bookmark
contributed by < OscarShiang >
Counting Bits (LeetCode 338)
The solution is separated into 2 parts:
iterate from 0 to n
count 1's of each number
To compute the 1's of a number, I apply the idea that the result of a & (a - 1) will always be the value of a without the least significant 1.
Oscar Shiang changed 4 years agoView mode Like Bookmark
測驗 $\alpha-1$
舉出 Linux 核心原始程式碼裡頭 bit rotation 的案例並說明
首先在 Linux source code include/linux/bitops.h 可以看到關於 bitops 的實作
這邊以 8 bit 的實作舉例:
static inline __u8 rol8(__u8 word, unsigned int shift)
{
Oscar Shiang changed 4 years agoView mode Like Bookmark