2010/12/12

Slides:



Advertisements
Similar presentations
FCU, Department of ECE, IC Design Research Lab. TEL: # 4945 Pre-SIm , Post-Sim.
Advertisements

1 生物計算期末作業 暨南大學資訊工程系 2003/05/13. 2 compare f1 f2  只比較兩個檔案 f1 與 f2 ,比完後將結果輸出。 compare directory  以兩兩比對的方式,比對一個目錄下所有檔案的相 似程度。  將相似度很高的檔案做成報表輸出,報表中至少要.
Chapter 10 馬可夫鏈 緒言 如果讀者仔細觀察日常生活中所發生的 諸多事件,必然會發現有些事件的未來 發展或演變與該事件現階段的狀況全然 無關,這種事件稱為獨立試行過程 (process of independent trials) ;而另一些 事件則會受到該事件現階段的狀況影響。
Introduction to Java Programming Lecture 13 Classes I OO Programming.
學習C++的基本語法 認識關鍵字與識別字的不同 學習程式碼偵錯的流程 學習如何提高程式的可讀性
:Word Morphing ★★☆☆☆ 題組: Problem Set Archive with Online Judge 題號: 10508:word morphing 解題者:楊家豪 解題日期: 2006 年 5 月 21 日 題意: 第一行給你兩個正整數, 第一個代表下面會出現幾個字串,
1 Q10276: Hanoi Tower Troubles Again! 星級 : ★★★ 題組: Online-judge.uva.es PROBLEM SET Volume CII 題號: Q10276: Hanoi Tower Troubles Again! 解題者:薛祖淵 解題日期: 2006.
Reference, primitive, call by XXX 必也正名乎 誌謝 : 部份文字取於前輩 TAHO 的文章.
What is static?. Static? 靜態 ? class Test { static int staticX; int instanceX; public Test(int var1, int var2) { this.staticX = var1; this.instanceX =
1 Web of Science 利用指引 單元二 瀏覽與處理查詢結果. 2 瀏覽檢索結果 查出的結果,預設以時間排列, 使用者可改變結果的排列方式: 還可以依被引用次數、相關度、 第一作者、刊名、出版年等排序 回到前先查的結果畫面 點選想看資料的完整書目 本館訂購範圍的期刊 全文,便可直接連結.
: Boxes ★★★☆☆ 題組: Problem Set Archive with Online Judge 題號: 11003: Boxes 解題者:蔡欣燁 解題日期: 2007 年 3 月 19 日.
亂數產生器安全性評估 之統計測試 SEC HW7 姓名:翁玉芬 學號:
: OPENING DOORS ? 題組: Problem Set Archive with Online Judge 題號: 10606: OPENING DOORS 解題者:侯沛彣 解題日期: 2006 年 6 月 11 日 題意: - 某間學校有 N 個學生,每個學生都有自己的衣物櫃.
第 18 章 名稱空間與例外處理 18-1 名稱空間 18-1 名稱空間 18-2 例外處理 18-2 例外處理.
程式註解說明. 2 程式註解格式 塊狀註解 對檔案、 class 、 method 、資料結構、一段程式 …. 等程式區塊 做說明。 第一行的開頭必需為 “/*” 且沒有其他文字,最後一行的開頭 必需以 “*/” 做為結束,在中間每一行的開頭都必需是一個 “*” 。 單行註解 佔據一整行的說明。 以.
Monte Carlo Simulation Part.2 Metropolis Algorithm Dept. Phys. Tunghai Univ. Numerical Methods C. T. Shih.
第 7 章 程序與函數 7-1 模組化程式設計 7-1 模組化程式設計 7-2 VB.NET 的程序與函數 7-2 VB.NET 的程序與函數 7-3 程序與函數的變數範圍 7-3 程序與函數的變數範圍 7-4 VB.NET 常用的內建函數 7-4 VB.NET 常用的內建函數 7-5 遞迴函數 7-5.
Introduction to Java Programming Lecture 5: Using Java Classes : String & Math Spring 2009.
第 1 章 PC 的基本構造. 本章提要 PC 系統簡介 80x86 系列 CPU 及其暫存器群 記憶體: Memory 80x86 的分節式記憶體管理 80x86 的 I/O 結構 學習組合語言的基本工具.
Introduction to Java Programming Lecture 17 Abstract Classes & Interfaces.
計算機概論 - 排序 1 排序 (Sorting) 李明山 編撰 ※手動換頁.
最新計算機概論 第 5 章 系統程式. 5-1 系統程式的類型 作業系統 (OS) : 介於電腦硬體與 應用軟體之間的 程式,除了提供 執行應用軟體的 環境,還負責分 配系統資源。
Matlab Assignment Due Assignment 兩個 matlab 程式 : Eigenface : Eigenvector 和 eigenvalue 的應用. Fractal : Affine transform( rotation, translation,
Chapter 20 塑模動態觀點:狀態圖 Statechart Diagram. 學習目標  說明狀態圖的目的  定義狀態圖的基本記號  展示狀態圖的建構  定義活動、內部事件及遞延事件的狀態 圖記號.
Digital Signal Processing with Examples in M ATLAB ® Chap 1 Introduction Ming-Hong Shih, Aug 25, 2003.
CH.8 偵錯 Visual Basic CH.8 偵錯 Visual Basic  資三甲   章乃云 三種類型的錯誤 三種類型的錯誤.
Chapter 2 Getting Started Insertion Sort: 能有效率地排序小數字的演算法 範例 :
Unit C: Analysing data characteristics 主要參考資料來源 : KPMG ACL 課程講義資料 PriceWaterHouseCooper ACL 課程講義資料 ACL Training Materials.
:Nuts for nuts..Nuts for nuts.. ★★★★☆ 題組: Problem Set Archive with Online Judge 題號: 10944:Nuts for nuts.. 解題者:楊家豪 解題日期: 2006 年 2 月 題意: 給定兩個正整數 x,y.
從此處輸入帳號密碼登入到管理頁面. 點選進到檔案管理 點選「上傳檔案」上傳資料 點選瀏覽選擇電腦裡的檔案 可選擇公開或不公開 為平台上的資料夾 此處為檔案分類,可顯示在展示頁面上,若要參加 MY EG 競賽,做品一律上傳到 “ 98 MY EG Contest ” 點選此處確定上傳檔案.
資料結構實習-一 參數傳遞.
6-2 認識元件庫與內建元件庫 Flash 的元件庫分兩種, 一種是每個動畫專 屬的元件庫 (Library) ;另一種則是內建元 件庫 (Common Libraries), 兩者皆可透過 『視窗』功能表來開啟, 以下即為您說明。
Dynamic Multi-signatures for Secure Autonomous Agents Panayiotis Kotzanikolaou Mike Burmester.
1 Introduction to Java Programming Lecture 2: Basics of Java Programming Spring 2008.
公用品.  該物品的數量不會因一人的消費而受到 影響,它可以同時地被多人享用。 角色分配  兩位同學當我的助手,負責:  其餘各人是投資者,每人擁有 $100 , 可以投資在兩種資產上。  記錄  計算  協助同學討論.
: Problem G e-Coins ★★★☆☆ 題組: Problem Set Archive with Online Judge 題號: 10306: Problem G e-Coins 解題者:陳瀅文 解題日期: 2006 年 5 月 2 日 題意:給定一個正整數 S (0
宏觀經濟學之均衡點. 定義  非自願性失業 當工人預備以現有的名義工資水平去接受工作,但 未能找到工作時,這種稱為非自願性失業。  通貨膨脹 所有名義價格持續上升。
Management Abstracts Retrieval System; MARS 檢索操作.
4.1 Operating System Concepts 第四章 執行緒 Threads n 綜觀 n 多重執行緒模型 (Multithreading Models) n 執行緒的相關問題 n Pthreads n Solaris 2 Threads n Windows 2000 Threads n.
: Beautiful Numbers ★★★★☆ 題組: Problem Set Archive with Online Judge 題號: 11472: Beautiful Numbers 解題者:邱經達 解題日期: 2011 年 5 月 5 日 題意: 若一個 N 進位的數用到該.
Section 4.2 Probability Models 機率模式. 由實驗看機率 實驗前先列出所有可能的實驗結果。 – 擲銅板:正面或反面。 – 擲骰子: 1~6 點。 – 擲骰子兩顆: (1,1),(1,2),(1,3),… 等 36 種。 決定每一個可能的實驗結果發生機率。 – 實驗後所有的實驗結果整理得到。
Teacher : Ing-Jer Huang TA : Chien-Hung Chen 2015/6/25 Course Embedded Systems : Principles and Implementations Weekly Preview Question CH 2.4~CH 2.6 &
函式 Function Part.2 東海大學物理系‧資訊教育 施奇廷. 遞迴( Recursion ) 函式可以「呼叫自己」,這種動作稱為 「遞迴」 此程式的執行結果相當於陷入無窮迴圈, 無法停止(只能按 Ctrl-C ) 這給我們一個暗示:函式的遞迴呼叫可以 達到部分迴圈的效果.
Image Interpolation Use SSE 指導教授 : 楊士萱 學 生 : 楊宗峰 日 期 :
JAVA 程式設計與資料結構 第二十章 Searching. Sequential Searching Sequential Searching 是最簡單的一種搜尋法,此演 算法可應用在 Array 或是 Linked List 此等資料結構。 Sequential Searching 的 worst-case.
演算法 8-1 最大數及最小數找法 8-2 排序 8-3 二元搜尋法.
2010 MCML introduction 製作日期: 2010/9/10 製作人 : 胡名霞.
1 第七章 植基於可調整式量化表及離散餘 弦轉換之浮水印技術. 2 Outlines 介紹 介紹 灰階浮水印藏入 灰階浮水印藏入 灰階浮水印取回 灰階浮水印取回 實驗結果 實驗結果.
逆向選擇和市場失調. 定義  資料不對稱 在交易其中,其中一方較對方有多些資料。  逆向選擇 出現在這個情況下,就是當買賣雙方隨意在 市場上交易,與比較主動交易者作交易為佳 。
845: Gas Station Numbers ★★★ 題組: Problem Set Archive with Online Judge 題號: 845: Gas Station Numbers. 解題者:張維珊 解題日期: 2006 年 2 月 題意: 將輸入的數字,經過重新排列組合或旋轉數字,得到比原先的數字大,
Linguistics phonetic symbols. 先下載 IPA 字型檔案,執行安裝。 由於這個程式的字型目錄設定錯誤, 所以等重新開機時就會發現字型消失。 所以必須根據以下步驟來讓 Windows 加入 IPA 字型。
Chapter 10 m-way 搜尋樹與B-Tree
第12章 多重表單與模組的應用程式 12-1 VB.NET的方案與專案 12-2 模組化VB.NET應用程式 12-3 多重表單的應用程式
: Function Overloading ★★★☆☆ 題組: Problem Set Archive with Online Judge 題號: 11032:Function Overloading 解題者:許智祺 解題日期: 2007 年 5 月 8 日 題意:判對輸入之數字是否為.
概念性產品企劃書 呂學儒 李政翰.
1 Introduction to Java Programming Lecture 2: Basics of Java Programming Spring 2009.
SQL 進階查詢.
第 6 章 迴圈結構 6-1 計數迴圈 6-1 計數迴圈 6-2 條件迴圈 6-2 條件迴圈 6-3 巢狀迴圈 6-3 巢狀迴圈 6-4 While/End While 迴圈 6-4 While/End While 迴圈 6-5 跳出迴圈 6-5 跳出迴圈 6-6 VB.NET 的錯誤處理 6-6 VB.NET.
資料結構實習-六.
1 Introduction to Java Programming Lecture 2: Basics of Java Programming Spring 2010.
第8章 字串與陣列 8-1一維陣列的處理 8-2 字串處理 8-3 多維陣列的處理 8-4 動態陣列與參數傳遞 8-5 陣列排序與搜尋.
多媒體技術與應用 實習作業 Part II. 實習作業 利用 Corel Paint Shop Pro X2 完成作業。 作業一:利用影像處理的技巧,讓這張影像變 的更清晰。
Introduction to Java Programming Lecture 16 Super and Sub Classes.
: Finding Paths in Grid ★★★★☆ 題組: Contest Archive with Online Judge 題號: 11486: Finding Paths in Grid 解題者:李重儀 解題日期: 2008 年 10 月 14 日 題意:給一個 7 個 column.
:Problem E.Stone Game ★★★☆☆ 題組: Problem Set Archive with Online Judge 題號: 10165: Problem E.Stone Game 解題者:李濟宇 解題日期: 2006 年 3 月 26 日 題意: Jack 與 Jim.
Mapping - 1 Mapping From ER Model to Relational DB.
第 1 章 PC 的基本構造. 本章提要 PC 系統簡介 80x86 系列 CPU 及其暫存器群 記憶體: Memory 80x86 的分節式記憶體管理 80x86 的 I/O 結構 學習組合語言的基本工具.
Failure Candidate Identification for Silicon Debug 指導教授 : 曾王道 學生 : 卜竹君 許正明.
(1) 化學方程式都可以表示哪些意義 ? 复習化學方程式的相關內容 : Zn + 2HCl ZnCl 2 + H 2 金屬也可用鎂 (Mg) 或鐵 (Fe) ;酸也可用稀硫酸來代替 MnO 2 2KClO 3 2KCl + 3O 2 Δ ( 實驗室制氧氣 ) ( 實驗室制氫氣 )
Presentation transcript:

2010/12/12

fruit store’s stock system

Purpose To practice the “producer & consumer” concept, which requires students to use pthread and at the same time use mutual exclusion. –Chapter 6 To understand why we need to design multi-threads program by practicing odd-even algorithm. Key words: pthread, producer & consumer, mutual exclusion, odd-even algorithm. Key words: pthread, producer & consumer, mutual exclusion, odd-even algorithm.

Introduction This program simulate a fruit store’s stock system. First, purchase different kinds of fruits and record all the orders. Second, classify them into different department. At last, sort them by given properties. In this project, you need to use pthread to implement a program with producer & consumer concepts and the odd-even algorithm.

Requirement Given different input files with tagged data, students have to output the correct order by sorting. Needs to implement the pthread with producer & consumer concepts and odd-even algorithm. During your demonstration, students needs to fix their program instructed by given requirements.

Input Command format apple orange grape1.txt 2.txt 3.txt

buffer Input #1 Input #2 Input #3 Basket #1 Basket #2 Basket #3 Output command P1 P2 P3 C1 C2 C3 Odd-Even Sorting Date flow

Requirement- Part I Mutual Exclusion buffer Apple Orange Appele Grape Orange Apple Orange Input #1 Input #2 Input #3 Input #4 Producer #1 Producer #2 Producer #3 Producer #4

Requirement-Part II Mutual Exclusion buffer Apple Orange Appele Grape Orange Apple Orange Basket #1 Basket #3 Basket #2 Consumer #1 Consumer #2 Consumer #3

Requirement- Part III Basket #1 Basket #2 Basket #3 Output #1 Output #2 Output #3 Odd-Even Sorting

Input files format(1.txt) Tag(Type)dateamountPrice

Example

buffer Input #1 Input #2 Input #3 Basket #1 Basket #2 Basket #3 Output command P1 P2 P3 C1 C3 Odd-Even Sorting O C2 Output Output #1

Example apple orange grape1.txt 2.txt 3.txt

Each consumer need to sort the fruit by assign properties(date 、 amount 、 price), and write to the output file Use Odd-even transposition sort Sorting

buffer Input #1 Input #2 Input #3 Basket #1 Basket #2 Basket #3 command P1 P2 P3 C1 C2 C3 Odd-Even Sorting Output Output #1 OOOO

Example- Output apple.txt orange.txt grape.txt

Odd-Even Transposition Sort Odd-Even Transposition Sort functions by comparing all indexed pairs of adjacent elements in the list and, if a pair is in the wrong order the elements are switched. The next step repeats this for indexed pairs Then it alternates between and steps until the list is sorted. It can be thought of as using parallel processors, each using bubblesort but starting at different points in the list.

Odd-Even Transposition Sort 1 st sort(even): 2 nd sort(odd):

Odd-Even Transposition Sort After sorting origin step1 step2 step3 step4 step5 step6

Example - Input 1.txt 2.txt 3.txt

Example- Output apple.txt orange.txt grape.txt

Grades Program(40%) Compile and Run(10%) Correctness(30%) Code(50%) Producer & consumer(20%) Mutual Exclusion(10%) Buffer ‘s structure(10%) Odd-even transposition sort(10%) Bonus Report (10%)

Notice: Individual work Demo date( deadline as well) 1/17-1/19, depends on the time you register for demo. Needs to demo on workstation.

Reminder(1/3) apple, orange, grape 是指不同的水果 ( 籃子 ) ,跟 input 裡 頭的名稱會對應且一致,也就是分放到不同籃子的依據 。 input 檔案沒有硬性規定數量,根據 input 的檔案數量, 就產生多少的 producer 來處理 input 檔案 ( 每個 producer 只處理一個 input file ,把所有資訊丟到同一個 buffer 中 )

Reminder(2/3) 整體流程大致上是: 1. 主執行緒 main() 讀入參數 2. 主執行緒根據 input files 個數產生對應數量的 producer , 每個 producer 擁有其中一個檔案 ( 指標或名稱 ) ,並讀取 該檔案的內容,將每一個水果資料放到共用的 Buffer 中

Reminder(3/3) 3. 主執行緒根據水果種類個數產生對應數量的 consumer , 每個 consumer 負責取一種水果到籃子裡 ( 也就是從共用 的 Buffer 讀取資料,若是 B 該筆水果資料屬於自己負責, 就從 Buffer 取出,放到籃子裡,這裡的籃子,可以是每 個 consumer 的區域變數 ) 4. producer 和 consumer 執行期間, producer 從檔案取資料 丟到 buffer , consumer 從 buffer 取資料出來丟到籃子裡 ,直到 Buffer 中的水果都處理完。 5. Buffer 的水果都取出之後,才開始進行排序。

Reference Chapter 6 Project- Producer & Consumer Odd-Even Sort