LuSkywalker

@luswdev

Joined on Jul 3, 2018

  • 首頁 RT-Thread 一個支援多種開發板的即時作業系統,我在做論文前閱讀的筆記。 原始碼 GitHub | 官方文本 Thread 排程 Thread Scheulder Clock Timer
     Like  Bookmark
  • Thread Thread Create st=>start: start 1 e=>end: end e1=>end: return init=>condition: init attribute stk_sz=>operation: Set Stack Size chk_poli=>condition: FIFO or
     Like  Bookmark
  • 13.1 多變數函數 $$ \begin{split} z &=& f(x,y)\ D &=& {(x,y)|x,y\in \mathbb{R}}\ R &=& {z|z\in f(x,y)} \end{split} $$ $D$:定義域(domin),注意分母不為 $0$、根號裡面 $\ge0$
     Like  Bookmark
  • 使用此管理方式: #define RT_USING_MEMPOOL [color=#66BB6A] mempool 的管理方法(靜態管理): 從 RAM 中要一塊記憶體 將此記憶體切成固定大小的區塊 以間接定址的方式接起來,形成 free list 結構 :::success
     Like 1 Bookmark
  • 車子 $1500+$1167=$2667/天 Day 1: $381/人 Day 2: $242/人 Day 3: $334/人 油錢粗估 $500/人 飯店
     Like  Bookmark
  • CPU 執行一個 porcess 時,是不斷的進行:讀取指令、增加程式計數器、執行指令的迴圈;但有時候一個程式需要進入 kernel,而不是執行下一行指令;包括:設備信號的發出、使用者程式做一些非法的事或是呼叫一個 system call。 處理上述情況有三大挑戰: Kernel 需使處理器能夠從 user mode 轉至 kernel mode(再轉回來)。 Kernel 及設備須協調好他們平行的活動。 Kernel 需了解設備的介面。 System call,例外及中斷
     Like 2 Bookmark
  • 智慧型物聯網跌倒偵測預警裝置系統 跌倒偵測 穿戴裝置 預警功能 動機 防止獨居老人不慎跌倒時可使用 陀螺儀
     Like  Bookmark
  • OS 必須具備三項技能:多工、獨立及交流。 kernel 組織 Monolithic kernel:整個 OS 都位於 kernel 中,如此一來所有 system calls 都會在 kernel 中執行(xv6)。 好處 設計者不須決定 OS 的哪些部份不需要完整的硬體特權。 更方便的讓不同部份的 OS 去合作。
     Like 1 Bookmark
  • 即一種值為 1 的特殊 semaphore,特別的是具有防止優先級翻轉的特性 結構 :::success File: rtdef.h ::: #ifdef RT_USING_MUTEX /** * Mutual exclusion (mutex) structure
     Like  Bookmark
  • 特性:可接受不固定長度的訊息 結構 :::success File: rtdef.h ::: #ifdef RT_USING_MESSAGEQUEUE /** * message queue structure
     Like  Bookmark
  • 使用此管理方式: #defined RT_USING_HEAP && #defined RT_USING_SMALL_MEM[color=#66BB6A] 與 memory heap 的做法類似,一開始是一塊大的記憶體,包含 header 分配記憶體時適當的切割 所有的記憶體塊透過 header 串起來,形成一個雙向鏈結 :::success File: mem.c :::
     Like  Bookmark
  • --- tags: note --- # 實驗室筆記 ## C語言 - [C語言 attribute](/@callumlu/c-lang-attr) ## Linux 相關 - [vim 指令](/@callumlu/vim) - [ubuntu 更改家目錄位置](/@callumlu/ubuntu-change-home) - [使用 crontab 自動備份網站原始碼](/@callumlu/crontab-backup) ## 網站相關 - [自訂網域名稱:Google Domain](/@callumlu/google-domain-hexo)
     Like  Bookmark
  • # RT-Thread GUI 繪圖引擎-硬體 Rtgui 中的 dc(drawable canvas) 也就是繪圖引擎,可以說是 rtgui 中最重要的一個部分,其中分成 3 個部分:給硬體的 dc_hw、給 buffer 的 dc_buffer 以及給 client 的。 接下來將會追蹤 dc_hw 中的程式碼,分析 rtgui 是如何在螢幕上面描繪點線面。 --- ## 結構 :::success **File:** dc.h ::: ### dc ```c=63 /* * The abstract device context * * Normally, a DC is a drawable canvas, user can draw point/line/cycle etc * on the DC. * * There are several kinds of DC: * - Hardware DC; * - Client DC; * - Buffer DC; */ struct rtgui_dc { /* type of device co
     Like  Bookmark
  • --- tags: GUI, RT-Thread --- # RT-Thread GUI engine RT-Thread 的 GUI 放在 package 中([git 原始碼](https://github.com/RT-Thread-packages/gui_engine.git)),本文將簡單將此 GUI engine 分工。 - [首頁](/@callumlu/rt-gui) ## System 系統層面的工作、及協助外部硬體,如鍵盤等。 ``` |-- src | |-- filerw.c | |-- mouse.c | |-- mouse.h | |-- server.c | |-- rtgui_app.c | |-- rtgui_driver.c | |-- rtgui_object.c | |-- rtgui_system.c | |-- include | |-- rtgui | |-- driver.h | |-- event.h |
     Like  Bookmark
  • # RT-Thread GUI Window ## 結構 :::success **File:** window.h ::: ```c=88 struct rtgui_win { /* inherit from container */ rtgui_container_t parent; /* update count */ rt_base_t update; /* drawing count */ rt_base_t drawing; struct rtgui_rect drawing_rect; /* parent window. RT_NULL if the window is a top level window */ struct rtgui_win *parent_window; struct rtgui_region outer_clip; struct rtgui_rect outer_extent; /* the widget that will grab the
     Like  Bookmark
  • # RT-Thread GUI Widget 上一篇我們說明了 RTGUI 是如何透過 C 實現物件導向的設計邏輯,這篇將會說明在 RTGUI 中的最小物件 "widget" 是如何創建、運行及刪除的。 ## 結構 :::success **File:** widget.h ::: ```c=86 /* * the base widget object */ struct rtgui_widget { /* inherit from rtgui_object */ struct rtgui_object object; /* the widget that contains this widget */ struct rtgui_widget *parent; /* the window that contains this widget */ struct rtgui_win *toplevel; /* the widget children and sibling */ rtgui_list_t siblin
     Like  Bookmark
  • # RT-Thread GUI Object ## RT-Thread GUI 物件架構 在 RTGUI 中,最小的物件為 widget,再來是 window,window 也是一個 widget;而每個 widget 也是一個 object,這是為了仿造 C++ 的物件導向所設計的,相同的概念我們在 RT-Thread 中已經看過許多次了,在 GUI engine 中也是相同的設計,其中在 object 結構中又串在 type 的結構上,type 中定義了兩個函式:`constructor` 與 `destructor`,在 C++ 的 class 中,常使用 `init` 函式來初始化新建的 class,這裡的 `constructor` 與 `destructor` 即用來初始化新建立的物件,及在刪除物件時,釋放該釋放的記憶體。[^1] [^1]:[RTGUI粗讲(个人见解篇之三、RTGUI WIDGET (2))](https://blog.csdn.net/xuzhenglim/article/details/11883351) --- ## 結構 :::success
     Like  Bookmark
  • # RT-Thread GUI Server ## 基本事件結構 server 掌管整個 GUI system 的所有事件 (event),而根據不同的事件定義不同的結構;在每個不同的結構中都有基本的欄位 `_RTGUI_EVENT_WIN_ELEMENTS`: :::success **File:** event.h ::: ```c=149 /* * RTGUI Window Event */ #define _RTGUI_EVENT_WIN_ELEMENTS \ struct rtgui_event parent; \ struct rtgui_win *wid; ``` `rtgui_event` 即為事件的基本結構: ```c=108 struct rtgui_event { /* the event type */ enum _rtgui_event_type type; /* user field of event */ rt_uint16_t user; /* the event sender */
     Like  Bookmark
  • --- tags: RT-Thread, kernel, Memory --- # RT-Thread 記憶體管理 - 分配記憶體的時間需固定,而且可確定(可預測)的 - 分配記憶體同時也要盡量避免碎片化,才能減少系統需重啟的次數 - RT-Thread 使用了靜態與動態管理,其中動態又分為小記憶體管理,與大記憶體管理(SLAB) - [記憶體管理](/@callumlu/rt-thread-mem?type=view) - [Memory Pool](/@callumlu/rt-thread-mem-pool) - [Memory Heap](/@callumlu/rt-thread-mem-heap) - [Slab](/@callumlu/rt-thread-mem-slab) - [小記憶體動態管理](/@callumlu/rt-thread-mem-small)
     Like  Bookmark
  • # RT-Thread SLAB 動態管理 >使用此管理方式: `#defined RT_USING_HEAP && #defined RT_USING_SLAB`[color=#66BB6A] SLAB 將記憶體根據不同的對象切成不同的區 (zone),對象通常是大小,也可看成是一個 zone 代表一個 pool,不同的 zone 放在一個 array 管理。 一個 zone 大小介於 32kB~128kB 之間,最多可以有 72 種 zone;zone 對象大小上上限 16kB,超過由頁分配器分配 - alloc:根據需要的大小,找到對應的 zone 取得記憶體;如假設需要 32kB,我們去尋找對象為 32kB 的 zone。 - 若是該 zone 為空(找不到),直接向頁分配器分配一個新的 zone,取得第一塊 free chunk - 若非空,直接取得第一塊,如果拿完該 zone 已經沒有 free chunk 頁分配器須將此 zone 刪除 - free:找到對應的 zone 插入至 free list,如果該 zone 的所有 free chunk
     Like  Bookmark