星期四, 10月 15, 2009

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

Q1 Define the difference between Preemptive and Non-preemptive scheduling. State why strict non-preemptive scheduling is unlikely to be used in a computer centre, suggest a better scheme for interactive users.


Preemptive scheduling allows a process to be interrupted in the midst of its execution, taking the CPU away from it and allocating it to another process.

Non-preemptive scheduling ensures that a process relinquishes control of the CPU only when it finishes with its current burst.

Non-preemptive would not likely be used in a computer centre, especially in a time sharing system, because it cannot guarantee that each user gets a share of the CPU at regular intervals. Non-preemptiveness allows programs to run infinitely long thus making turnaround time (response time) for other submitted jobs even longer.

Round-Robin is a preemptive scheme that makes use of interrupt/context switching operation to allow processor switching between jobs. Long jobs cannot delay shorter ones, because short jobs are guaranteed of getting the processor periodically. Interactive users will thus receive the processor frequently enough to maintain good response times.





Q2 Explain the difference in degree to which the following scheduling algorithms discriminate in favour of short jobs.(i) First Come, First Served(ii) Round Robin(iii) Multi-level feedback queues


(i) First Come, First Served (FCFS) - discriminates against short jobs since any short jobs arriving after long jobs will have a long waiting time.
(ii) Round-Robin - treats all jobs equally (giving them equal bursts of CPU time) so short jobs will be able to leave the system faster since they will finish first.
(iii) Multi-Level Feedback Queues - discriminate very favourably toward short jobs since it works similar to the round robin algorithm.






Q3 What effect does the size of time quantum have on the performance of a round robin (RR) algorithm?



At one extreme, if the time quantum is extremely large, the RR policy is the same as the FCFS policy. If the time quantum is small, it must be large with respect to context switch, otherwise overhead is too high.






Q4 What advantage is there in having different quantum sizes on different levels of a multi-level feedback queuing system ?



The advantage is that the short jobs will have highest priority if they are shorter than the initial quantum. This serves them fast and frees the CPU to concentrate on longer jobs.
The jobs that are pushed to the next level (lower priority), now can be given more time than the initial quantum since the goal is to run as many programs as fast as possible with minimal delays to other programs.
Therefore, by increasing the quantum with the level, shorter jobs will be allowed higher priority, and longer jobs will be allowed to run simultaneously with minimum delays.

星期一, 10月 12, 2009

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

Q1 List the four major categories of the benefits of multithreaded programming. Briefly explain each.

The benefits of multithreaded programming fall into the categories: responsiveness, resource sharing, economy, and utilization of multiprocessor architectures.
Responsiveness means that a multithreaded program can allow a program to run even if part of it is blocked. Resource sharing occurs when an application has several different threads of activity within the same address space. Threads share the resources of the process to which they belong. As a result, it is more economical to create new threads than new processes. Finally, a single threaded process can only execute on one processor regardless of the number of processors actually present. Multiple threads can run on multiple processors, thereby increasing efficiency.

Q2 What resources are used when a thread is created ?
How do they differ from those used when a process is created ?

Thread context must be created, including a register set, location for storage during a context switching and a local stack to record the procedure call arguments, return values and return addresses and thread local storage.
Code and data are shared with parent process or parent thread (no loading or allocation of memory necessary).

Process creation similar to thread storage (as above), with extra storage for program instructions and data.
Codes and data may be loaded for every process into the allocated memory and no sharing with other processes.


Q3 What is a thread pool and why is it used?

A thread pool is a collection of threads, created at process startup, that sit and wait for work to be allocated to them. This allows one to place a bound on the number of concurrent threads associated with a process and reduce the overhead of creating new threads and destroying them at termination.

Q4 What are the differences between user-level threads and kernel-support threads ?

User-levels thread have no kernel support, so they are very inexpensive (in terms of resources demand) to create, destroy, and switch among threads do not cause interrupt to CPU.

Kernel support thread are more expensive (in resources) because system calls are needed to create and destroy them and the kernel must schedule them to share access to CPU. They are more powerful because they are independently scheduled and block individually.

星期四, 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。

推薦此文