YLowy

@YLowy

Joined on Aug 13, 2020

  • Debug always make developer sad, especially in a big system. How to debug in Linux Kernel? Tracing In early kernel patch, we have some tracing tools, e.g. strace, gdb. They are all based on the old tracing system call: ptrace. GDB gdb -q test.o strace
     Like  Bookmark
  • refer: https://thenewstack.io/how-io_uring-and-ebpf-will-revolutionize-programming-in-linux/ io_uring Classic IO system call For UDP's receive system call, it can be divided into two stages, wait for data and copy data to user space. Kernel offered the following blocking system calls to deal with file descriptors, be they storage files or sockets: size_t read(int fd, void *buf, size_t count); size_t write(int fd, const void *buf, size_t count);
     Like  Bookmark
  • 1. uclib vs glib uclib ->https://git.uclibc-ng.org/git/uclibc-ng.git uClibc-ng is a small C library for developing embedded Linux systems. It is much smaller than the GNU C Library, but nearly all applications supported by glibc also work perfectly with uClibc-ng. In strlen() function, the "finding zero in long size string" is different between glib and uclib. See Here //uclib
     Like  Bookmark
  • We often use the strlen(str) function to get the length of the string. This is broad-use, and simply implemented. In C, we cannot consider a string as an object. We need to find the '\0'(NULL) character to determine the end of the string. C11 6.4.5 6. a byte or code of value zero is appended to each multibyte character sequence that results from a string literal or literals. C11 7.1.1 A string is a contiguous sequence of characters terminated by and including the first null character. The term multibyte string is sometimes used instead to emphasize special processing given to multibyte characters contained in the string or to avoid confusion with a wide string. A pointer to a string is a pointer to its initial (lowest addressed)
     Like  Bookmark
  • Reference The APEROS Code Review Elements APEROS (Availability, Performance, Extensibility, Resiliency, Observability, Scalability) Availability timeout / retry 的平衡 不該預設上下游的 input/output 都是可預期行為 考慮服務負載 可動態調整的 timeout / retry
     Like  Bookmark
  • The Transmission Control Protocol (TCP) uses a retransmission timer to ensure data delivery in the absence of any feedback from the remote data receiver. 參考: rfc793, rfc6298 , Congestion Avoidance and Control 在 TCP 通訊進行中雙方會存在需要等待對方回應時間。此段時間的大小存在許多因素像是網路環境,對方主機狀況…。而在 TCP 存在重新傳送機制,那此時就有個問題了:多久的時間沒有收到 TCP ACK 將會看作需要重新重算呢? RTO 計算 a TCP sender maintains two state
     Like  Bookmark
  • 3.1 History 3.2 Program Encoding unix> gcc -O1 -o p p1.c p2.c -O1 最佳化1 流程 C preprocessor expands the sourse code(#include) and MARCOs(#define). Complier -> generates the assembly code p1.s p2.s Assembler -> convert assembly code to machine code p1.o p2.o
     Like  Bookmark
  • https://leetcode.com/problems/longest-palindromic-substring/ Given a string s, return the longest palindromic substring in s. Manacher's Algorithm #define MIN(a,b) (a<b)?a:b char * longestPalindrome(char * s){ int s_len = strlen(s); char * s2 = s;
     Like  Bookmark
  • Solution 直覺寫法 #define MAX_INT (int)((unsigned)(-1)>>1) #define MIN_INT (int)(~MAX_INT) int reverse(int x){ if(x>=MAX_INT||x<=MIN_INT) return 0; int pos = (x>>31); int ans =0; x =pos?x*(-1):x;
     Like  Bookmark
  • hard Solution double findMedianSortedArrays(int* nums1, int nums1Size, int* nums2, int nums2Size){ int two; int myarraysize=0; two = (nums1Size+nums2Size)%2?1:2; // count of calulation myarraysize =((nums1Size+nums2Size)>>1)+1; int i=0,j=0;
     Like  Bookmark
  • Solution 1 直覺做法 int check(char * myarray, char c){ int val = (int)c; if(myarray[val]){ return 1;//char existed } else{ return 0;//
     Like  Bookmark
  • https://leetcode.com/problems/add-two-numbers/ Medium You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list. You may assume the two numbers do not contain any leading zero, except the number 0 itself. Solution /** * Definition for singly-linked list. * struct ListNode {
     Like  Bookmark
  • https://leetcode.com/problems/two-sum/ Description Input: nums = [2,7,11,15], target = 9 Output: [0,1] Output: Because nums[0] + nums[1] == 9, we return [0, 1]. Solution 1 直覺作法 ${O}$(${N^2}$)
     Like  Bookmark
  • contributed by < YLowy > 10.1 Unix I/O file descriptor 標準輸入輸出錯誤(0,1,2) <unistd.h> STDIN_FILENO STDOUT_FILENO
     Like  Bookmark
  • contributed by < YLowy > 前言 本篇會參照 lwan sample 中的 Hello World 進行程式碼部分解說 在好幾年前自己在學習 C 時,按照書上所提及 “如何寫一個簡單的網頁伺服器” 按部就班的透過 fork 做出可以支援多人連線的小程式,之後再也沒有更新過對於伺服器的了解 。 非常強烈的建議先參考老師的 高效能 Web 伺服器開發 可以更清楚的了解 lwan 其程式碼結構 Socket 通訊
     Like 2 Bookmark
  • 參照 wiki 所述 : Coroutines are computer program components that generalize subroutines for non-preemptive multitasking, by allowing execution to be suspended and resumed 程式可以透過 coroutine 實現 concurrency ( 非 parallelism )。 透過此可以在指定進入點以及離開點實現 non-preemptive multitasking ( 只能等待自己放棄資源其他爭奪的程式才能使用其資源 ),也就是說在只要進入所寫定紀錄點即可確保離開前不會被其他 generator 搶佔。但如果在 OS 中以multi-thread 運作 coroutine 還是要考慮 critical section 問題。 通常使用 Coroutine 會運作在目標為 hard-realtime context 之系統。 hard-realtime context
     Like 1 Bookmark
  • contributed by < YLowy > Web Framework Benchmarks 中 lwan web server 在 JSON serialization 中達到了第 12 名。其透過FrameworkBenchmarks測試各種不同的網頁之效能做排名。 ab.exe 不準? 對 seHTTPd 進行壓力測試 weighttp 工具 對local host 進行測試 :
     Like  Bookmark
  • contributed by < YLowy > 這個會一直動的時間怎麼做到的? https://www.jwz.org/xdaliclock/ lwan 利用 keep alive 的 chunked-encoding 製作一個 never-ending GIF。 :::info 不要嘗試下載他這個 gif,下載不完的。 :::
     Like  Bookmark
  • contributed by < YLowy > 事前準備 1. 下載映像檔 使用 Ubuntu 20.10 (Groovy Gorilla) 這邊我下載的是 Raspberry Pi Generic (64-bit ARM) preinstalled server image For modern Raspberry Pi boards (Pi 2, Pi 3 and Pi 4). 2. 將映像檔載入 Micro SD Card
     Like  Bookmark
  • 金象盃比賽細流規則 以 2020 南區初賽為例 最主要原則 : 比賽可以帶大抄筆記,使用工具不限,但不可使用手機以及其他通訊相關電子設備 比賽中不可使用其他網站,這邊要請工作人員比賽前口頭宣告 流程
     Like  Bookmark