chihenliu

@chihenliu

非本科雜魚

Joined on Feb 15, 2023

  • 相關連結: 作業系統及考古、計算機結構及考古、linux kernel學習筆記、STM32學習筆記 Output Problem Predict the output of below programs. 1. #include<stdio.h> int main() { int n; for(n = 7; n!=0; n--)
     Like  Bookmark
  • 中斷機制摘要 中斷的定義與作用 中斷:是一種能夠改變 CPU 執行流程的機制,用於處理外部事件或異常情況。 作用: 提高系統效率:允許 CPU 在等待 I/O 操作完成時,可以執行其他任務。 處理異常事件:如除零錯誤、記憶體存取錯誤等。 實現系統交互:如鍵盤、滑鼠等輸入設備的處理。
     Like  Bookmark
  • 在學及目前等兵單在各大論壇收集許多心得及面試準備方向和自學的資源,在此用hackmd整理一下並且當作學習進度的整理檢視自我的學習狀況也怕當兵後失智也方便自己複習,方便將來自己及後進及先進參考並且修改我自己對於某些CS和EE專業上的錯誤認知,還請各位多包涵。小弟的背景為地名理工學四大機械碩。 面試考題 C語言的0x10問題 預處理器(Preprocessor) 前置處理器或稱預處理器,會在程式編譯開始前先行作用,其目的是為了使程式碼更簡潔、可讀性更佳,參考Jserv老師的你所不知道的 C 語言:前置處理器應用篇中的一段話: 原來 C preprocessor 以獨立程式的形式存在,所以當我們用 gcc 或 cl (Microsoft 開發工具裡頭的 C 編譯器) 編譯給定的 C 程式時,會呼叫 cpp (伴隨在 gcc 專案的 C preprocessor) 一類的程式,先行展開巨集 (macro) 或施加條件編譯等操作,再來 才會出動真正的 C 語言編譯器 (在 gcc 中叫做 cc1) 可以讓我們更加了解一些其中的原理,主要的C語言程式執行過程的流程圖如下:image
     Like 1 Bookmark
  • C語言入門 你所不知道的 C 語言系列講座 資料型別 資料處理的核心問題:記憶及計算,這個問題會由資料型別用以描述這個資料如何儲存及計算。 電腦內部具有記憶體空間而該空間由Byte(8 bits)所組成大多數情況下(實作定義) image 任何資料型別的資料都是由0或1所組成,所以為何硬碟可以儲存照片、影音、word、PPT檔案等。 資料型別
     Like  Bookmark
  • contributed by < chihen0709 > 測驗題之改進 〈因為自動飲料機而延畢的那一年〉及 前五周課程 的啟發及心得 前五周課程之心得 先跟老師說聲抱歉,因為我不夠強,沒辦法跟著老師的進度走,前陣子因為論文被換題目,那一個多月都在應付指導教授所要求的進度,所以沒辦法將前幾周的課程教材和作業全數研讀完畢及做出相應的實作,目前是跟到約第三周的教材及課程,應會先將 homework2 及 lab0-c 實作程式碼及共筆於近期完成,目前跟到第三周快第四周的心得是:我一開始就知道這一門課會相較老師上學期開的計算機結構還要精實,我卻異想天開只需要付出計算機結構所花費的時間,就還能得到一些還行的成果,但這個想法根本就是不可行的,在第一周至第六周這種高強度的課程下,突然有種深深的絕望感,因為教材十分多,光是觀看講解的錄影跟教材就所耗時間不少加上要撰寫作業並且補足許多我未曾了解的資料結構以及演算法,都是耗費我許多時間的過程,加上中途被換題目那種深深的無力感,令我前陣子有想說退選這門課程,但仔細想想老師第一周的大綱就是誠實面對自己,我選修了這門課卻沒有好好的面對自己來學習這門課,老師所教的都是在刷新我原本對於 C 語言程式設計的認知,每份教材好好拜讀完成後才知道自己對於計算機科學領域是一無所知,一開始寫 lab0-c 時前幾個函式還可以慢慢想出來,一牽扯到自己沒學過的演算法就卡關,去參照過往學長的實作以及觀看同學們的共筆和在 Github 的提交,總是讓我很焦慮,為何程式流程規劃以及演算法跟資料結構都這麼精簡以及有效率,本來想說就此放棄,但還是先將 lab0-c 的最基本要求做完,轉而去應付換題目的窘境,看著同學們一直在臉書社團提問以及更新,總覺得自己離他們很遠,但就如同老師所說的誠實面對自己,或許我可能沒辦法做到那些強者同學們的程度,但我想通過這門課程更加了解 C 語言程式設計 以及作業系統相關的知識,並且最好能做出一個嵌入式系統的小專案是我在這門課程的目標,或許沒辦法像同學們真正提交 patch 至 linux kernel 但還是能從這門課學到一些我能帶走的東西,就如同老師上學期期末專案對我們所說的話就是希望我們能從這堂課學到一些東西並且能帶得走的,雖然我知道自己 C 語言超級不熟練、看 linux kernel 的程式碼一知半解、看英文規格書看得霧煞煞,但我還是會繼續跟完剩餘的課程,直至我離開成功大學,記得老師從課程一開始就一直跟我們講的事情:「要誠實面對自己。」,正是因為可以誠實面對自己,才可以坦然接受失敗,再從失敗中改進並且學習。 〈因為自動飲料機而延畢的那一年〉研讀心得 文章中提及
     Like  Bookmark
  • contributed by < chihen0709 > Reviewed by Chloexyw 在 q_insert_head 和 q_insert_tail 中有提到有使用函式 strncpy,但實際在 GitHub 中並沒有,若能將 GitHub 和共筆的資訊同步更新可以更方便他人進行討論 Reviewed by david965154 使用經過 clang-format 風格修正後的程式碼來解釋實作細節的部份。 在 q_merge 你提到了使用 Strategies for Stable Merge Sorting 來實作,在補上實作細節的同時請介紹其方法及如何實作,若與原本實作方法不同,可以說明使用了什麼方法作替代、造成的差異為何。
     Like  Bookmark
  • contributed by <chihen0709> 第一周測驗 題目 測驗1 原本 Quick Sort 會使用遞迴函式將 stack 來去存儲資料,但此實作是使用非遞迴函式的做法來去實作快速排序演算法,優點是相較於原本的快速排序演算法,少了呼叫函式這個步驟減少了進入函式並退出所佔用的處理器時間以及避免使用 stack 去儲存資料,遞迴函式只是將 stack 當作多餘的儲存空間,這樣來說其實沒有比實作中所使用兩個 array : begin[] 和 end[] 兩個 array 速度還快,還可能導致 stack 空間溢出會令呼叫排序的函式崩潰。 透過以上思路:先宣告一個鏈結串列結構體並利用以下函式來去操作。
     Like  Bookmark
  • Problem A Consider that we plan to deploy a custom RISC-V processor for a space mission, which requires additional data protection in memory. We have decided to implement a Hamming code with even parity to safeguard our data. For this question, please refer to the parity table shown below. image Please note that in this context, bit 0 is considered the least significant bit (LSB). What Are Bit Flips And How Are Spacecraft Protected From Them? [ ] Part 1 Implement a RISC-V function called calc_parity that takes a 4-byte input in a0 and calculates the parity of its bits. It should return 1 for odd parity or 0 for even parity. For example:
     Like  Bookmark
  • Problem A Consider an algorithm for transposing a square matrixin-place by swapping rows and columns. Below, you will find the C code for this operation, and it is important to note that the matrix elements are 32-bit integers. #include <stddef.h> void transpose(size_t n, int *m) { for (size_t i = 0; i < n; i++) { for (size_t j = i + 1; j < n; j++) { int t = m[(i * n) + j]; m[(i * n) + j] = m[(j * n) + i];
     Like  Bookmark
  • Problem A Consider a C implementation of the count leading zero function for 64-bit integers. A leading zero is defined as any ‘0’ digit that appears before the first non-zero digit in the binary representation of a number. Examples:Input : N = 16 Output : 59 Explanation: As Binary = (00000000000000000000000000000000 00000000000000000000000000010000) Input :
     Like  Bookmark
  • contributed By < chihenliu > linkedlist "linked list" is a common data structure As shown in the two diagrams above, the concept is to use nodes to record, represent, and store data. Each node has three components: Data, Pointer, and Address. Additionally, each node's pointer points to the address of the next node, continuing until it points to Null, signifying the end of this simple linked list. The time complexity is O(N) Count leading zero To calculate the number of consecutive zeros, counting from the Most Significant Bit (MSB) towards the right, until the first encountered '1' in a binary number Ex: 0000000000000010 =14
     Like  Bookmark
  • contributed by chihenliu 1.Environment Setup My OS is Ubuntu 22.04.3 LTS 1.1. Install the dependent package $sudo apt install build-essential verilator gtkwave 1.2.Install sbt/JDK/SDKMAN 1.2.1 Install SDKMAN follow the instructions install SDKman
     Like  Bookmark
  • contributed by < chihenliu > Problem select and Motivation this work I select Implement transformation from integer to float by clz from 洪碩星 I want to understand the conversion between floating points and integers, which is a fundamental concept in both C and assembly language. Additionally, I want to become familiar with the application of the GNU Toolchain to aid in this understanding IEEE 754 floating point IEEE 754 floating-point numbers consist of three components: the sign bit, exponent, and mantissa, and define special values like positive and negative infinity and NaN. This is a commonly used floating-point representation in the field of computing, IEEE754 floating point have two Common format single and double precision
     Like  Bookmark
  • Assignemnt 1:RISC-V Assembly and Instruction Pipeline contribute By<chihenliu> linkedlist "linked list" is a common data structure As shown in the two diagrams above, the concept is to use nodes to record, represent, and store data. Each node has three components: Data, Pointer, and Address. Additionally, each node's pointer points to the address of the next node, continuing until it points to Null, signifying the end of this simple linked list. The time complexity is O(N) Count leading zero To calculate the number of consecutive zeros, counting from the Most Significant Bit (MSB) towards the right, until the first encountered '1' in a binary number
     Like  Bookmark