星期四, 10月 08, 2009

CS3161 (A) OPERATING SYSTEM PRINCIPLES (DR. LIU WENYIN) (09CS3161_LW) - Answers to Tutorial 3 Questions

Q1 What is PCB? What information are usually stored in PCB?

PCB Stands for Process Control Block.

Process State
Program Counter
CPU Registers
CPU Scheduling information
Memory management information
I/O Status
Accounting information



Q2 Explain the concept of a context switch.

Whenever the CPU starts executing a new process, the old process's state must be preserved. The context of a process is represented by its process control block. Switching the CPU to another process requires performing a state save of the current process and a state restore of a different process. This task is known as a context switch. When a context switch occurs, the kernel saves the context of the old process in its PCB and loads the context of the new process scheduled to run.


Q3 Explain the main differences between a short-term and long-term scheduler.

The primary distinction between the two schedulers lies in the frequency of execution. The short-term scheduler is designed to frequently select a new process for the CPU, at least once every 100 milliseconds. Because of the short time between executions, the short-term scheduler must be fast. The long-term scheduler executes much less frequently; minutes may separate the creation of one new process and the next. The long-term scheduler controls the degree of multiprogramming. Because of the longer interval between executions, the long-term scheduler can afford to take more time to decide which process should be selected for execution.



Q4 We can describe much of processor management in terms of process state transition diagrams, such as:

Run 2 1 3 4 Wait Ready (Blocked)

(i) Give one example of "event" that causes each of the mark transitions ?
(ii) When we view all the processes in the system, we can see that a state transition by one process could cause another process to make a state transition also. Under what circumstances could transition 3 by one process immediately cause transition 1 by another process ? List all similar situations.


Q4 Process State Transitions

(i) Transition 1 - Last process completed or blocked, another process on the ready queue will be allocated the CPU for execution (Dispatch).
Transition 2 - Preemptive scheduling system
Transition 3 - Process requests an I/O operation
Transition 4 - I/O device completion, process joins the ready queue.

(ii) Process Transitions :
Process request I/O operation - When a process make an I/O service request (Transition 3), when the I/O device is not available at that time, it will go through a transition from run state to wait (blocked) state. At the same time another process on the ready queue will be allocated the CPU for execution (Transition 1) during that time.

Process exceeded the CPU allowance, completed execution or abortion in error condition (Transition 2), another process dispatch to use the CPU (Transition 1).

星期三, 10月 07, 2009

朗文電子課本 msvcr80.dll error

為何我的電子書在裝有 Microsoft Window Vista 或 Microsoft Office 2007 的電腦上運行不到?
由於 Microsoft Window Vista 和 Microsoft Office 2007 上有一個 dll 檔案和電子書有所衝突以致未能運作。解決方法如下:

1. 在你的硬碟〈例如:C drive〉上建立一個資料夾〈例如:ebook,不可以是中文名稱〉。
2. 把電子書光碟的所有檔案複製到新建立的資料夾〈例如:C:\ebook〉。
3. 到下列網址下載一個名為 2006_eBook_Update.zip 的檔案。
http://www.ilongman.com/temp/2006_eBook_Update.zip
4. 將上述檔案解壓於桌面,桌面上將會出現兩個檔案 〈shell.exe, main.exe〉。
5. 將上述兩個檔案複製到硬碟上的電子書 program 資料夾內〈例如:C\ebook\program〉,確定取代舊有的兩個檔案。
6. 啟動電子書資料夾內的 startcd.exe。

星期六, 10月 03, 2009

開心水族館養扇貝虧錢

養扇貝是一種浪費錢的舉動.....

不但虧錢, 連經驗值都不會給

算式如下:

扇貝一個1.2w,假若每次10小時都準時收成,那麼…
24h(天) x 15天(使用期限) = 360(H)
360(H) / 10(H) = 36顆
36顆 x 200元 = 7200元
12000-7200=4800(虧損)

星期二, 9月 22, 2009

什麼是影像

影像的分類:

一般影像分為點陣式圖及向量式圖。

點陣式圖,是由許多點所組合成的這些點又稱之為"像素"。點陣圖中就是記錄
這些像素的座標及顏色,非常真實,接近照片

也因為如此,所以點陣式的圖檔非常的大,且受解析度的限制,無法任意放大縮
小,否則就會出現鋸齒狀的線條與失真。但是其創造出的影像非常接近真實,而
且與影像軟體配合產生千變萬化的結果,是向量圖所不及的。

一般來說,點陣圖可經由掃描器掃描而的或由數位像機拍攝而得。而用來處理點
陣圖的軟體,常見的有:
Paint Shop、Adobe PhotoShop、Corel Photopaint、Ulead Photoimpact 等
向量式圖,不以點為記錄單位,而以繪圖元素為記錄單位的圖形。繪圖元素為點、
直線、圓、矩形等,每一圖形利用數學公式計算所使用的繪圖元素在圖形中的位
置、大小、方向等。

所以圖形放大縮小後,會重新計算資料,不會產生失真的問題。但是向量圖不是
忠實計錄每個點的色彩,不容易表現精緻的圖形。因為只記錄位置及計算公式等
資料,向量式圖檔案都不大。用來處理向量式圖的軟體,常見的有:
Corel DRAW、Adobe Iustrator 等。

影像類型:
16 色:一個影像用16 種顏色來表現。2^4=16
256 色:一個影像用256 種顏色來表現。2^8=256
全彩:一個影像用1677 萬種顏色來表現。2^24=1677 萬
PhotoImpact 可以開啟或儲存的格式很多,例如:BMP(點陣圖)、TIF、PSD(Photoshop
的檔案)、JPG(常應用於網路,壓縮檔)、GIF(常應用於網路)、UFO(友立
物件檔)

繪圖物件:
簡稱物件,直線、矩形、圓形、文字、插入的影像等都稱為繪圖物件,每一個單
一物件可以任意移動位置、改變大小等。

星期六, 9月 19, 2009

電子書 could't find library MSVCR80.dll?

為何我的電子書在裝有 Microsoft Window Vista 或 Microsoft Office 2007 的電腦上運行不到?

由於 Microsoft Window Vista 和 Microsoft Office 2007 上有一個 dll 檔案和電子書有所衝突以致未能運作。解決方法如下:

1. 在你的硬碟〈例如:C drive〉上建立一個資料夾〈例如:ebook,不可以是中文名稱〉。
2. 把電子書光碟的所有檔案複製到新建立的資料夾〈例如:C:\ebook〉。
3. 到下列網址下載一個名為 2006_eBook_Update.zip 的檔案。
http://www.ilongman.com/temp/2006_eBook_Update.zip
4. 將上述檔案解壓於桌面,桌面上將會出現兩個檔案 〈shell.exe, main.exe〉。
5. 將上述兩個檔案複製到硬碟上的電子書 program 資料夾內〈例如:C\ebook\program〉,確定取代舊有的兩個檔案。
6. 啟動電子書資料夾內的 startcd.exe。

星期四, 9月 10, 2009

rsync command Example

The following command will backup the desktop to the mybackups folder

rsync -rlpt --stats Desktop /volumes/LaCieDrive/mybackups

Options used above:
-r = Recursive, traverse into subdirectories
-l = Treat symlinks as symlinks; don't follow them
-p = Preserve permissions
-t = Preserve creation and modification dates and times
--stats = Show file transfer statistics

星期三, 9月 09, 2009

數碼相機的應用

數碼相機與今日記者形影不離,
數碼相機是一種以數碼形式記錄影像、毋須使用菲林的相機。

傳統相機以光學方式呈像在菲林上,幾乎是不失真的方法,
不過底片保存不易,在拍攝時有失誤又無法察覺,容易錯失珍貴畫面,
而且買底片也是一筆開銷。

數位相機以數位方式保存畫面,但是因為經過計算壓縮會有失真的情況,
但將畫面保存在記憶卡,燒成光碟保存,沒有不易保存的問題,
一但拍的不好可以立即重拍,
失敗的照片可以少很多,快捷、方面、便宜是它成功的原因。

推薦此文