李晨瑞

@terry23304

Joined on Sep 29, 2022

  • A process is a program in the midst of execution. Each thread includes a unique program counter, process stack and set of processor registers, kernel schedules individual threads, not process. To Linux thread is just a process which share resources with other process Kernel stores the list of processes in a circular doubly linked list called task list Process descriptor Each element in the task list is a process descriptor of the type struct task_struct task_struct 中儲存所有核心所需的 process 資訊,如:
     Like 1 Bookmark
  • contributed by < terry23304 and paulpeng > Preparation riscv-gnu-toolchain For 64-bit toolchain $ git clone https://github.com/riscv/riscv-gnu-toolchain $ sudo apt-get install autoconf automake autotools-dev curl python3 python3-pip libmpc-dev libmpfr-dev libgmp-dev gawk build-essential bison flex texinfo gperf libtool patchutils bc zlib1g-dev libexpat-dev ninja-build git cmake libglib2.0-dev $ cd riscv-gnu-toolchain $ mkdir build && cd build
     Like  Bookmark
  • contributed by < terry23304 > Hello World in Chisel class Hello extends Module { val io = IO(new Bundle { val led = Output(UInt(1.W)) }) val CNT_MAX = (50000000 / 2 - 1).U; val cntReg = RegInit(0.U(32.W)) val blkReg = RegInit(0.U(1.W))
     Like  Bookmark
  • contributed by < terry23304 > Choose a question Problem: I choose Implement Binarization by count leading zero from edenlin Add perfcounter to C code #include <stdint.h> #include <stdio.h> #include <stdint.h>
     Like  Bookmark
  • make check $ sudo dmesg > kernel_log.txt with open("kernel_log.txt", "r") as file: lines = file.readlines() with open("execution_times.txt", "w") as output_file: sample_number = 1 for line in lines:
     Like  Bookmark
  • contributed by < terry23304 > Determines the smallest power of two that is greater than a given integer. In this operation, the input integer is rounded up to the nearest power of two. C Code uint16_t count_leading_zeros(uint32_t x) { x |= (x >> 1); x |= (x >> 2); x |= (x >> 4);
     Like  Bookmark
  • 測驗 α − 1 測驗 β - 1 static inline uintptr_t align_up(uintptr_t sz, size_t alignment) { uintptr_t mask = alignment - 1; if ((alignment & mask) == 0) { /* power of two? */ return (sz + mask) & ~mask; } return (((sz + mask) / alignment) * alignment); }
     Like  Bookmark
  • Client-server model 每一個網路應用 ( network application) 是基於 client-server model Server 管理資源, 並且提供 client 操作這些資源的服務 (service) Client-server transiction ( 過渡/ or 溝通) 有 4 點 當 client 需要服務 (service), 它會發送 request 給 server e.g. Web browser 需要一張圖片, 它會送 request 給 Web server Server 接收 request, 並且處理請求內容
     Like  Bookmark
  • contributed by < terry23304 > 測驗 1 根據電腦結構設定 word_size ,header_size = sizeof(block_t) 更好理解 /* Size of a memory element, 32 or 64 bits */ enum { word_size = __SIZE_WIDTH__ / 8, /**< size of memory element */ #if __SIZE_WIDTH__ == 64 log2_word_size = 3,
     Like  Bookmark
  • contributed by < terry23304 > 測驗 1 把顏色資訊儲存在右子的最低位元中,最低位元為 1 則為紅, 0 為黑 #define rb_node(x_type) \ struct { \ x_type *left, *right_red; \ } insert
     Like  Bookmark
  • contributed by <terry23304> 測驗 1 typedef struct __node { uintptr_t color; struct __node *left, *right; struct __node *next; long value; } node_t __attribute__((aligned(sizeof(long)))); 透過 __attribute__((aligned(sizeof(long)))) 把 struct __node 對齊 sizeof(long)
     Like  Bookmark
  • :::spoiler 開發環境 $ gcc --version gcc (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0 Copyright (C) 2021 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit
     Like  Bookmark
  • contributed by < terry23304 > 測驗 1 運作原理 uint64_t next_pow2(uint64_t x) { x |= x >> 1; x |= x >> 1; x |= x >> 1; x |= x >> 1;
     Like  Bookmark
  • contributed by < terry23304 > 測驗 1 運作原理 digraph pic1 { rankdir = LR; {4->9->2->5->8}; } 取第一個 entry 當pivot,並把pivot移除串列
     Like  Bookmark
  • object object in c: 在執行時期資料儲存的區域,可以明確表示數值內容 C99 [6.2.4] Storage durations of objectsAn object has a storage duration that determines its lifetime. There are three storage durations: static, automatic, and allocated. C99 [6.5.3.2] Address and indirection operators &: called address of *: called value of or indirection The unary & operator yields the address of its operand. If the operand has type ‘‘type’’, the result has type ‘‘pointer to type’’. If the operand is the result of a unary * operator, neither that operator nor the & operator is evaluated and the result is as if both were omitted, except that the constraints on the operators still apply and the result is not an lvalue. 若&的 operand 是*兩個 operator都會被省略
     Like  Bookmark
  • contributed by < terry23304 > 開發環境 $ gcc --version gcc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0 Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit Byte Order: Little Endian Address sizes: 39 bits physical, 48 bits virtual CPU(s): 16
     Like  Bookmark