SlideShare a Scribd company logo
Concurrency
林敬倫, 蘇文鈺
成大資訊
2010/11
Why Concurrency?
•
•
•
•

Real-Life system is concurrent
Machines work concurrently
Circuits work concurrently
Software processes execute concurrently. Here, events
are usually used to handle concurrency problems.
• So, we use concurrent processes to model a system.
• Therefore, the simulation kernel has to handle the
execution of concurrent processes.
• In SystemC, thread and method are two main process
types.
sc_event
• An event happens at a specific time instant and carries no
value and duration. So, when it occurs, no trace of its
occurrence can be located except the effects it causes.
• SystemC simulation kernel is an event-driven simulator.
• SystemC uses sc_event which is responsible for launching and
triggering of events.
• sc_event happens at a single point of time.
• To observe an event, there must be processes waiting for it
and firing actions for it such that we know its occurrence.
• you can perform only two actions with an sc_event: wait for it
or cause it to occur.
• Syntax: sc_event name_of_event, …;
• A scheduled event can be cancelled by
name_of_event.cancel();
Simplified Simulation Kernel

[From SystemC From the Groud Up]
How SystemC simulation Kernel Works
• Process is ready for execution when the
events it waits are triggered.
• Processes waits for a certain time period to
return to their execution.
• This period can be zero delay or a certain
amount of cycles. If zero delay, they are ready
for execution. Otherwise, they will be placed
in waiting list until the amount of cycles
passes.
Process execution and Event Pools

[From SystemC From the Groud Up]
More on Kernel Operation
• SystemC kernel enters the waiting state
whenever it encounters an explicit wait(), or
in some cases performs a return.
– For zero delay, it is called a delta cycle delay.
Related processes are moved to ready list.
– For non-zero delay, processes are moved to the
ready list when the time is advanced to the
scheduled time is met.
– When no process is to be executed for a triggered
event, it simply returns to sc_main and finished.
Use SC_THREAD as Process
• An SC_THREAD is started once and only once.
• An sc_thread takes control when it is started and
returns (wait() inside of a loop) to the kernel or
simply exits (return) after its execution.
• When a SC_THREAD exits, it terminates
forever, so, SC_THREAD usually contains an
infinite loop.(while(1);) and at least one wait().
• An indirect method to invoke wait() is to call
blocking methods like sc_fifo read or write.
Trigger of an Event using .notify()
• To cause an event to occur, .notify() can be used.
• Usages:
– name_of_event .notify(); //immediate notification
– name_of_event .notify(SC_ZERO_TIME);//delayed
notification
– name_of_event .notify(time);//timed notification
– notify(name_of_event)
– notify(name_of_event, SC_ZERO_TIME);
– notify(name_of_event, time);

• Events can be cancelled by using .cancel(), but
immediate events, which happen at the present
notification time, cannot be cancelled.
Effects of notify
• When using notify(), kernel moves processes
waiting for the from the wait pool into the
ready list.
• Notified Processes will execute only after all
waiting processes have executed.
• An sc_event may have no more than a single
outstanding scheduled event, and only the
nearest time notification is allowed.
Dynamic Sensitivity of sc_thread using
wait()
• Wait() is used to suspend an sc_thread.
• When wait() is executed, the state of the
current sc_thread is saved and SystemC
simulation kernel takes back its control.
• Then, the kernel tries to activate the next
ready process.
• When the suspended thread resumes, its
saved context is restored before continuing its
execution.
Syntax of wait()
•
•
•
•
•

wait(time);
wait(name_of_event);
wait(name_of_event1&name_of_event2&…);
wait(timeout, name_of_event);
wait(timeout, name_of_event1 |
name_of_event2 | …….);
• wait();// static sensitivity
• …. And so on.
Time_out()
• Use time_out() to test a system
sc_event event1, event2;
….
wait(time, event1|event2);
If(time_out()) break;
….
If(event2) printf(…..);
…….
Simulation Scenarios in Different
Perspects
User Perceives

Actual in SystemC Kernel

[From SystemC From the Groud Up]
Use SC_METHOD as Process
• It is like a function call in C. Therefore, it is less
suitable to modeling some behavior.
• It runs completely and returns and may not
suspend internally. Thus, wait() cannot be used
here.
• Based one sensitivity, it is called repeated by the
simulation kernel. Therefore, it is more like
Verilog always@() statement.
• There are also implied waits such as read/write of
sc_fifo, which should be avoided in sc_method.
Using SC_METHOD and its Sensitivity
• Syntax:
– SC_METHOD(name_of_process);

• Using an SC_METHOD, variables must be
declared and initialized each time when it is
invoked.
• Sensitivity: the way it can be called repeatedly
and synchronized with other processes
– Dynamic
– Static
Dynamic Sensitivity of SC_METHOD
• next_trigger()
–
–
–
–
–

next_trigger(time);
next_trigger(event);
next_trigger(name_of_event1&name_of_event2&…);
next_trigger(timeout, name_of_event);
next_trigger(timeout, name_of_event1 |
name_of_event2 | …….);
– next_trigger();// static sensitivity
– …. And so on.

• Looks exactly the same as wait();
Using next_trigger()
• It should be initialized and executed before the
return of this SC_METHOD.
• It is important to apply next_trigger() at every
exit path in a SC_METHOD. Otherwise, it will
never be invoked again.
• To avoid the situation that a method is never
called again, one can place a default next_trigger
as its first statement.
• It can be repeatedly called. Each time it is
called, the previous ones are override.
Processing Order
of wait() and next_trigger()
• wait(name_of_event1&name_of_event2&…)/nex
t_trigger(name_of_event1&name_of_event2&…)
;
– There is no knowing which event comes first:
name_of_event1 or name_of_event2. It can be
asserted that both events happen.

• wait(name_of_event1|name_of_event2&…)/next
_trigger(name_of_event1|name_of_event2&…);
– It can be asserted that either events or both events
happen. To know which event happen, additional
code is required, like the time_out() example.
Static Sensitivity
• Static sensitivity is established during the elaboration
stage and cannot be changed once it is established.
• It applies to the most recent process registration. It is
used when processes are handled for certain fixed
events without implementing the related codes in the
processes bodies.
• Thread: wait();// static sensitivity
• Method: next_trigger();// static sensitivity

• Syntax:
– sensitive << name_of_event1 [<< name_of_event2];
– sensitive (name_of_event, …);
Example:using event & next_trigger
• Hello_module:
– Thread1:執行五次後會對thread2發出通知,執行
八次後會對method發出通知並將記數器歸零.
– Thread2:執行兩次後會等待thread1的通知再繼
續進行;執行三次後會對method發出通知並將記
數器歸零.
– Method:等待thread1及thread2的通知,並在
thread2通知執行過後,將只接受thread1的通知
(即thread2的通知將被忽略).
Main.cpp
#include <systemc.h>
#include "hello_module.h"
int sc_main(int argc, char* argv[])
{
// signal declaration
sc_clock
clk("clk", 10, SC_NS, 0.5);

// module declaration
hello_module
module0("hello_word");
// signal connection
module0.clk(clk);
// run simulation
sc_start(1000, SC_NS);
return 0;
}
Hello_module.h
//Constructor
SC_CTOR(hello_module) {
count1 = 0;
count2 = 0;

#include <systemc.h>

SC_MODULE(hello_module)
{
// signal declaration
sc_in_clk
clk;

SC_THREAD(thread_func1);
sensitive << clk.pos();

// fuction declaration
void thread_func1();
void thread_func2();
void method_func();

SC_METHOD(method_func);
sensitive << T1toM;
sensitive << T2toM;

SC_THREAD(thread_func2);
sensitive << clk.pos();

}
//event declaration
sc_event T1toT2, T1toM, T2toM;
int count1, count2;
};
Hello_moule.cpp(1/3)
#include "hello_module.h"
void hello_module::thread_func1()
{
while(1){
wait();
count1++;
sc_time_stamp().print();
printf(" Thread1 : n");
if(count1 == 5){
printf(" Thread1 : T1toT2.notify() n");
T1toT2.notify();
}
if(count1 == 8){
printf(" Thread1 : T1toM.notify() n");
T1toM.notify();
count1 = 0;
}}}
Hello_moule.cpp(2/3)
void hello_module::thread_func2()
{
while(1){
wait();
count2++;
sc_time_stamp().print();
printf(" Thread2 : n");
if(count2 == 2){
printf(" Thread2 : wait for T1.notify1 n");
wait(T1toT2);
}
if(count2 == 3){
printf(" Thread2 : T2toM.notify() n");
T2toM.notify();
count2 = 0;
}
}
}
Hello_moule.cpp(3/3)
void hello_module::method_func()
{
if(clk){
sc_time_stamp().print();
printf(" Method : Hello Word! n");
//當T2toM叫起methodu第一次之後,T2toM將會失去作用.
next_trigger(T1toM);
}
}
Be Careful of Processing Order
• One must be sure of the processing order of
processes, because different processor orders
may cause different results.
• Sometimes, wrong process order may cause
simulation errors though the program can be
successfully compiled and no runtime error.
• 書中figure 7-16 to 7-19舉了一個例子. 請大家看
一下, 然後寫一個簡單的例子, 當沒有figure7-17
中的wait(SC_ZERO_TIME)時, simulation結果會
有何不同呢?
上一頁裡提出的問題
• 若沒有wait(SC_ZERO_TIME),則無法確定
turn_knob_thread()會在stop_signal_thread()
執行後才執行,若是turn_knob_thread()先執
行,所做出event.notify()的動作將會因為
stop_signal_thread()之中的event尚未執行
wait(event)因此出現模擬錯誤.
• 因此需要wait(SC_ZERO_TIME)將
turn_knob_thread()放置整個cycle最後才執
行,否則執行結果將不是正確的模擬結果.
HW3
• 請設計以下四個模組:
– 模組一: 系統一開始時讀入一文字檔(純英文),並讀入要搜尋的兩
個關鍵字。
– 模組二: 每個時脈時自模組一接收一個word,遇標點符號時丟棄
之。
– 模組三: 每當模組二接到一個非標點符號的word時,自模組二接收
此一word,並檢查是否為第一個關鍵字,若是,則計數器加一。
– 模組四: 每當模組二接到一個非標點符號的word時,自模組二接收
此一word,並檢查是否為第二個關鍵字,若是,則計數器加一。
– 文件結束時,模組三與模組數四通知模組一其個別之數目,模組
一印出數目後,讀入新的檔案。此處理直到該目錄下之檔案均被
檢查完後結束。

• 模組中必須含有method與thread,其他你可能需要再設計其他
模組來進行四個模組的控制,此一模組之設計則無限制。
• 模組間之資料傳輸此次不限定要用SystemC的預設介面
• 請用OpenESL作此一作業。2010/12/9,11:59PM繳交。

More Related Content

What's hot

Uvm dcon2013
Uvm dcon2013Uvm dcon2013
Uvm dcon2013sean chen
 
Detecting hardware virtualization rootkits
Detecting hardware virtualization rootkitsDetecting hardware virtualization rootkits
Detecting hardware virtualization rootkits
Edgar Barbosa
 
Operating Systems 1 (8/12) - Concurrency
Operating Systems 1 (8/12) - ConcurrencyOperating Systems 1 (8/12) - Concurrency
Operating Systems 1 (8/12) - ConcurrencyPeter Tröger
 
java memory management & gc
java memory management & gcjava memory management & gc
java memory management & gc
exsuns
 
Austin c-c++-meetup-feb2018-spectre
Austin c-c++-meetup-feb2018-spectreAustin c-c++-meetup-feb2018-spectre
Austin c-c++-meetup-feb2018-spectre
Kim Phillips
 
Software Profiling: Java Performance, Profiling and Flamegraphs
Software Profiling: Java Performance, Profiling and FlamegraphsSoftware Profiling: Java Performance, Profiling and Flamegraphs
Software Profiling: Java Performance, Profiling and Flamegraphs
Isuru Perera
 
Implementing STM in Java
Implementing STM in JavaImplementing STM in Java
Implementing STM in Java
Misha Kozik
 
Sstic 2015 detailed_version_triton_concolic_execution_frame_work_f_saudel_jsa...
Sstic 2015 detailed_version_triton_concolic_execution_frame_work_f_saudel_jsa...Sstic 2015 detailed_version_triton_concolic_execution_frame_work_f_saudel_jsa...
Sstic 2015 detailed_version_triton_concolic_execution_frame_work_f_saudel_jsa...
Jonathan Salwan
 
Java in flames
Java in flamesJava in flames
Java in flames
Isuru Perera
 
Java util concurrent
Java util concurrentJava util concurrent
Java util concurrent
Roger Xia
 
Concurrency bug identification through kernel panic log (english)
Concurrency bug identification through kernel panic log (english)Concurrency bug identification through kernel panic log (english)
Concurrency bug identification through kernel panic log (english)
Sneeker Yeh
 
UVM Update: Register Package
UVM Update: Register PackageUVM Update: Register Package
UVM Update: Register PackageDVClub
 
Valgrind tutorial
Valgrind tutorialValgrind tutorial
Valgrind tutorial
Satabdi Das
 
BlueHat v18 || Hardening hyper-v through offensive security research
BlueHat v18 || Hardening hyper-v through offensive security researchBlueHat v18 || Hardening hyper-v through offensive security research
BlueHat v18 || Hardening hyper-v through offensive security research
BlueHat Security Conference
 
Tasklet vs work queues (Deferrable functions in linux)
Tasklet vs work queues (Deferrable functions in linux)Tasklet vs work queues (Deferrable functions in linux)
Tasklet vs work queues (Deferrable functions in linux)
RajKumar Rampelli
 
Valgrind overview: runtime memory checker and a bit more aka использование #v...
Valgrind overview: runtime memory checker and a bit more aka использование #v...Valgrind overview: runtime memory checker and a bit more aka использование #v...
Valgrind overview: runtime memory checker and a bit more aka использование #v...
Minsk Linux User Group
 
How Triton can help to reverse virtual machine based software protections
How Triton can help to reverse virtual machine based software protectionsHow Triton can help to reverse virtual machine based software protections
How Triton can help to reverse virtual machine based software protections
Jonathan Salwan
 
BlueHat v18 || A mitigation for kernel toctou vulnerabilities
BlueHat v18 || A mitigation for kernel toctou vulnerabilitiesBlueHat v18 || A mitigation for kernel toctou vulnerabilities
BlueHat v18 || A mitigation for kernel toctou vulnerabilities
BlueHat Security Conference
 
Lowering STM Overhead with Static Analysis
Lowering STM Overhead with Static AnalysisLowering STM Overhead with Static Analysis
Lowering STM Overhead with Static Analysis
Guy Korland
 
Linux on System z debugging with Valgrind
Linux on System z debugging with ValgrindLinux on System z debugging with Valgrind
Linux on System z debugging with Valgrind
IBM India Smarter Computing
 

What's hot (20)

Uvm dcon2013
Uvm dcon2013Uvm dcon2013
Uvm dcon2013
 
Detecting hardware virtualization rootkits
Detecting hardware virtualization rootkitsDetecting hardware virtualization rootkits
Detecting hardware virtualization rootkits
 
Operating Systems 1 (8/12) - Concurrency
Operating Systems 1 (8/12) - ConcurrencyOperating Systems 1 (8/12) - Concurrency
Operating Systems 1 (8/12) - Concurrency
 
java memory management & gc
java memory management & gcjava memory management & gc
java memory management & gc
 
Austin c-c++-meetup-feb2018-spectre
Austin c-c++-meetup-feb2018-spectreAustin c-c++-meetup-feb2018-spectre
Austin c-c++-meetup-feb2018-spectre
 
Software Profiling: Java Performance, Profiling and Flamegraphs
Software Profiling: Java Performance, Profiling and FlamegraphsSoftware Profiling: Java Performance, Profiling and Flamegraphs
Software Profiling: Java Performance, Profiling and Flamegraphs
 
Implementing STM in Java
Implementing STM in JavaImplementing STM in Java
Implementing STM in Java
 
Sstic 2015 detailed_version_triton_concolic_execution_frame_work_f_saudel_jsa...
Sstic 2015 detailed_version_triton_concolic_execution_frame_work_f_saudel_jsa...Sstic 2015 detailed_version_triton_concolic_execution_frame_work_f_saudel_jsa...
Sstic 2015 detailed_version_triton_concolic_execution_frame_work_f_saudel_jsa...
 
Java in flames
Java in flamesJava in flames
Java in flames
 
Java util concurrent
Java util concurrentJava util concurrent
Java util concurrent
 
Concurrency bug identification through kernel panic log (english)
Concurrency bug identification through kernel panic log (english)Concurrency bug identification through kernel panic log (english)
Concurrency bug identification through kernel panic log (english)
 
UVM Update: Register Package
UVM Update: Register PackageUVM Update: Register Package
UVM Update: Register Package
 
Valgrind tutorial
Valgrind tutorialValgrind tutorial
Valgrind tutorial
 
BlueHat v18 || Hardening hyper-v through offensive security research
BlueHat v18 || Hardening hyper-v through offensive security researchBlueHat v18 || Hardening hyper-v through offensive security research
BlueHat v18 || Hardening hyper-v through offensive security research
 
Tasklet vs work queues (Deferrable functions in linux)
Tasklet vs work queues (Deferrable functions in linux)Tasklet vs work queues (Deferrable functions in linux)
Tasklet vs work queues (Deferrable functions in linux)
 
Valgrind overview: runtime memory checker and a bit more aka использование #v...
Valgrind overview: runtime memory checker and a bit more aka использование #v...Valgrind overview: runtime memory checker and a bit more aka использование #v...
Valgrind overview: runtime memory checker and a bit more aka использование #v...
 
How Triton can help to reverse virtual machine based software protections
How Triton can help to reverse virtual machine based software protectionsHow Triton can help to reverse virtual machine based software protections
How Triton can help to reverse virtual machine based software protections
 
BlueHat v18 || A mitigation for kernel toctou vulnerabilities
BlueHat v18 || A mitigation for kernel toctou vulnerabilitiesBlueHat v18 || A mitigation for kernel toctou vulnerabilities
BlueHat v18 || A mitigation for kernel toctou vulnerabilities
 
Lowering STM Overhead with Static Analysis
Lowering STM Overhead with Static AnalysisLowering STM Overhead with Static Analysis
Lowering STM Overhead with Static Analysis
 
Linux on System z debugging with Valgrind
Linux on System z debugging with ValgrindLinux on System z debugging with Valgrind
Linux on System z debugging with Valgrind
 

Viewers also liked

Esl basics
Esl basicsEsl basics
Esl basics
敬倫 林
 
Track c-High speed transaction-based hw-sw coverification -eve
Track c-High speed transaction-based hw-sw coverification -eveTrack c-High speed transaction-based hw-sw coverification -eve
Track c-High speed transaction-based hw-sw coverification -evechiportal
 
Top five reasons why every DV engineer will love the latest systemverilog 201...
Top five reasons why every DV engineer will love the latest systemverilog 201...Top five reasons why every DV engineer will love the latest systemverilog 201...
Top five reasons why every DV engineer will love the latest systemverilog 201...
Srinivasan Venkataramanan
 
A Systematic Approach to Creating Behavioral Models (white paper) v1.0
A Systematic Approach to Creating Behavioral Models (white paper) v1.0A Systematic Approach to Creating Behavioral Models (white paper) v1.0
A Systematic Approach to Creating Behavioral Models (white paper) v1.0Robert O. Peruzzi, PhD, PE, DFE
 
SystemVerilog Assertions (SVA) in the Design/Verification Process
SystemVerilog Assertions (SVA) in the Design/Verification ProcessSystemVerilog Assertions (SVA) in the Design/Verification Process
SystemVerilog Assertions (SVA) in the Design/Verification ProcessDVClub
 
How to Connect SystemVerilog with Octave
How to Connect SystemVerilog with OctaveHow to Connect SystemVerilog with Octave
How to Connect SystemVerilog with Octave
Amiq Consulting
 
UVM Ral model usage
UVM Ral model usageUVM Ral model usage
UVM Ral model usage
Parth Pandya
 
SystemVerilog Assertions verification with SVAUnit - DVCon US 2016 Tutorial
SystemVerilog Assertions verification with SVAUnit - DVCon US 2016 TutorialSystemVerilog Assertions verification with SVAUnit - DVCon US 2016 Tutorial
SystemVerilog Assertions verification with SVAUnit - DVCon US 2016 Tutorial
Amiq Consulting
 
stack
stackstack
stack
Raj Sarode
 
Design and Implementation of an Advanced DMA Controller on AMBA-Based SoC
Design and Implementation of an Advanced DMA Controller on AMBA-Based SoCDesign and Implementation of an Advanced DMA Controller on AMBA-Based SoC
Design and Implementation of an Advanced DMA Controller on AMBA-Based SoC
Rabindranath Tagore University, Bhopal
 
Queue
QueueQueue
Queue
Raj Sarode
 
Tree
TreeTree
Queue
QueueQueue
Processes and threads
Processes and threadsProcesses and threads

Viewers also liked (17)

Esl basics
Esl basicsEsl basics
Esl basics
 
MixedSignal UVM Demo CDNLive
MixedSignal UVM Demo CDNLiveMixedSignal UVM Demo CDNLive
MixedSignal UVM Demo CDNLive
 
Track c-High speed transaction-based hw-sw coverification -eve
Track c-High speed transaction-based hw-sw coverification -eveTrack c-High speed transaction-based hw-sw coverification -eve
Track c-High speed transaction-based hw-sw coverification -eve
 
Top five reasons why every DV engineer will love the latest systemverilog 201...
Top five reasons why every DV engineer will love the latest systemverilog 201...Top five reasons why every DV engineer will love the latest systemverilog 201...
Top five reasons why every DV engineer will love the latest systemverilog 201...
 
A Systematic Approach to Creating Behavioral Models (white paper) v1.0
A Systematic Approach to Creating Behavioral Models (white paper) v1.0A Systematic Approach to Creating Behavioral Models (white paper) v1.0
A Systematic Approach to Creating Behavioral Models (white paper) v1.0
 
SystemVerilog Assertions (SVA) in the Design/Verification Process
SystemVerilog Assertions (SVA) in the Design/Verification ProcessSystemVerilog Assertions (SVA) in the Design/Verification Process
SystemVerilog Assertions (SVA) in the Design/Verification Process
 
How to Connect SystemVerilog with Octave
How to Connect SystemVerilog with OctaveHow to Connect SystemVerilog with Octave
How to Connect SystemVerilog with Octave
 
UVM Ral model usage
UVM Ral model usageUVM Ral model usage
UVM Ral model usage
 
SystemVerilog Assertions verification with SVAUnit - DVCon US 2016 Tutorial
SystemVerilog Assertions verification with SVAUnit - DVCon US 2016 TutorialSystemVerilog Assertions verification with SVAUnit - DVCon US 2016 Tutorial
SystemVerilog Assertions verification with SVAUnit - DVCon US 2016 Tutorial
 
stack
stackstack
stack
 
Design and Implementation of an Advanced DMA Controller on AMBA-Based SoC
Design and Implementation of an Advanced DMA Controller on AMBA-Based SoCDesign and Implementation of an Advanced DMA Controller on AMBA-Based SoC
Design and Implementation of an Advanced DMA Controller on AMBA-Based SoC
 
Queue
QueueQueue
Queue
 
Tree
TreeTree
Tree
 
Queue
QueueQueue
Queue
 
Processes and threads
Processes and threadsProcesses and threads
Processes and threads
 
Queuing Theory
Queuing TheoryQueuing Theory
Queuing Theory
 
SystemC
SystemCSystemC
SystemC
 

Similar to Concurrency 2010

Operating system 24 mutex locks and semaphores
Operating system 24 mutex locks and semaphoresOperating system 24 mutex locks and semaphores
Operating system 24 mutex locks and semaphores
Vaibhav Khanna
 
Operating Systems
Operating Systems Operating Systems
Operating Systems
Ziyauddin Shaik
 
AOS Lab 6: Scheduling
AOS Lab 6: SchedulingAOS Lab 6: Scheduling
AOS Lab 6: SchedulingZubair Nabi
 
Chapter 2 (Part 2)
Chapter 2 (Part 2) Chapter 2 (Part 2)
Chapter 2 (Part 2) rohassanie
 
CIS3110 Winter 2016CIS3110 (Operating Systems) Assig.docx
CIS3110 Winter 2016CIS3110 (Operating Systems) Assig.docxCIS3110 Winter 2016CIS3110 (Operating Systems) Assig.docx
CIS3110 Winter 2016CIS3110 (Operating Systems) Assig.docx
clarebernice
 
Dead Lock Analysis of spin_lock() in Linux Kernel (english)
Dead Lock Analysis of spin_lock() in Linux Kernel (english)Dead Lock Analysis of spin_lock() in Linux Kernel (english)
Dead Lock Analysis of spin_lock() in Linux Kernel (english)
Sneeker Yeh
 
Timers in Unix/Linux
Timers in Unix/LinuxTimers in Unix/Linux
Timers in Unix/Linuxgeeksrik
 
Lecture18-19 (1).ppt
Lecture18-19 (1).pptLecture18-19 (1).ppt
Lecture18-19 (1).ppt
ssuserf67e3a
 
Threads in Java
Threads in JavaThreads in Java
Threads in Java
Gaurav Aggarwal
 
UNIX Notes
UNIX NotesUNIX Notes
UNIX Notes
PandurangBiradar2
 
FreeRTOS Slides annotations.pdf
FreeRTOS Slides annotations.pdfFreeRTOS Slides annotations.pdf
FreeRTOS Slides annotations.pdf
AbdElrahmanMostafa87
 
Process scheduling
Process schedulingProcess scheduling
Process scheduling
Hao-Ran Liu
 
Qt Application Programming with C++ - Part 2
Qt Application Programming with C++ - Part 2Qt Application Programming with C++ - Part 2
Qt Application Programming with C++ - Part 2
Emertxe Information Technologies Pvt Ltd
 
Unit 2_OS process management
Unit 2_OS process management Unit 2_OS process management
Unit 2_OS process management
JayeshGadhave1
 
Linux synchronization tools
Linux synchronization toolsLinux synchronization tools
Linux synchronization toolsmukul bhardwaj
 
Intro Basic of OS .ppt
Intro Basic of OS .pptIntro Basic of OS .ppt
Intro Basic of OS .ppt
Varsha506533
 
Multithreaded Programming Part- III.pdf
Multithreaded Programming Part- III.pdfMultithreaded Programming Part- III.pdf
Multithreaded Programming Part- III.pdf
Harika Pudugosula
 
Operating System.pptx
Operating System.pptxOperating System.pptx
Operating System.pptx
VanshikaRajput33
 
Chapter -2 operating system presentation
Chapter -2 operating system presentationChapter -2 operating system presentation
Chapter -2 operating system presentation
chnrketan
 
Embedded Recipes 2018 - Finding sources of Latency In your system - Steven Ro...
Embedded Recipes 2018 - Finding sources of Latency In your system - Steven Ro...Embedded Recipes 2018 - Finding sources of Latency In your system - Steven Ro...
Embedded Recipes 2018 - Finding sources of Latency In your system - Steven Ro...
Anne Nicolas
 

Similar to Concurrency 2010 (20)

Operating system 24 mutex locks and semaphores
Operating system 24 mutex locks and semaphoresOperating system 24 mutex locks and semaphores
Operating system 24 mutex locks and semaphores
 
Operating Systems
Operating Systems Operating Systems
Operating Systems
 
AOS Lab 6: Scheduling
AOS Lab 6: SchedulingAOS Lab 6: Scheduling
AOS Lab 6: Scheduling
 
Chapter 2 (Part 2)
Chapter 2 (Part 2) Chapter 2 (Part 2)
Chapter 2 (Part 2)
 
CIS3110 Winter 2016CIS3110 (Operating Systems) Assig.docx
CIS3110 Winter 2016CIS3110 (Operating Systems) Assig.docxCIS3110 Winter 2016CIS3110 (Operating Systems) Assig.docx
CIS3110 Winter 2016CIS3110 (Operating Systems) Assig.docx
 
Dead Lock Analysis of spin_lock() in Linux Kernel (english)
Dead Lock Analysis of spin_lock() in Linux Kernel (english)Dead Lock Analysis of spin_lock() in Linux Kernel (english)
Dead Lock Analysis of spin_lock() in Linux Kernel (english)
 
Timers in Unix/Linux
Timers in Unix/LinuxTimers in Unix/Linux
Timers in Unix/Linux
 
Lecture18-19 (1).ppt
Lecture18-19 (1).pptLecture18-19 (1).ppt
Lecture18-19 (1).ppt
 
Threads in Java
Threads in JavaThreads in Java
Threads in Java
 
UNIX Notes
UNIX NotesUNIX Notes
UNIX Notes
 
FreeRTOS Slides annotations.pdf
FreeRTOS Slides annotations.pdfFreeRTOS Slides annotations.pdf
FreeRTOS Slides annotations.pdf
 
Process scheduling
Process schedulingProcess scheduling
Process scheduling
 
Qt Application Programming with C++ - Part 2
Qt Application Programming with C++ - Part 2Qt Application Programming with C++ - Part 2
Qt Application Programming with C++ - Part 2
 
Unit 2_OS process management
Unit 2_OS process management Unit 2_OS process management
Unit 2_OS process management
 
Linux synchronization tools
Linux synchronization toolsLinux synchronization tools
Linux synchronization tools
 
Intro Basic of OS .ppt
Intro Basic of OS .pptIntro Basic of OS .ppt
Intro Basic of OS .ppt
 
Multithreaded Programming Part- III.pdf
Multithreaded Programming Part- III.pdfMultithreaded Programming Part- III.pdf
Multithreaded Programming Part- III.pdf
 
Operating System.pptx
Operating System.pptxOperating System.pptx
Operating System.pptx
 
Chapter -2 operating system presentation
Chapter -2 operating system presentationChapter -2 operating system presentation
Chapter -2 operating system presentation
 
Embedded Recipes 2018 - Finding sources of Latency In your system - Steven Ro...
Embedded Recipes 2018 - Finding sources of Latency In your system - Steven Ro...Embedded Recipes 2018 - Finding sources of Latency In your system - Steven Ro...
Embedded Recipes 2018 - Finding sources of Latency In your system - Steven Ro...
 

Recently uploaded

Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
Matthew Sinclair
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
Octavian Nadolu
 
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex ProofszkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
Alex Pruden
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
Kumud Singh
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
DianaGray10
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
sonjaschweigert1
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
Neo4j
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Nexer Digital
 
GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...
ThomasParaiso2
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
James Anderson
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
KAMESHS29
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
Neo4j
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Aggregage
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 

Recently uploaded (20)

Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
 
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex ProofszkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
 
GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 

Concurrency 2010

  • 2. Why Concurrency? • • • • Real-Life system is concurrent Machines work concurrently Circuits work concurrently Software processes execute concurrently. Here, events are usually used to handle concurrency problems. • So, we use concurrent processes to model a system. • Therefore, the simulation kernel has to handle the execution of concurrent processes. • In SystemC, thread and method are two main process types.
  • 3. sc_event • An event happens at a specific time instant and carries no value and duration. So, when it occurs, no trace of its occurrence can be located except the effects it causes. • SystemC simulation kernel is an event-driven simulator. • SystemC uses sc_event which is responsible for launching and triggering of events. • sc_event happens at a single point of time. • To observe an event, there must be processes waiting for it and firing actions for it such that we know its occurrence. • you can perform only two actions with an sc_event: wait for it or cause it to occur. • Syntax: sc_event name_of_event, …; • A scheduled event can be cancelled by name_of_event.cancel();
  • 4. Simplified Simulation Kernel [From SystemC From the Groud Up]
  • 5. How SystemC simulation Kernel Works • Process is ready for execution when the events it waits are triggered. • Processes waits for a certain time period to return to their execution. • This period can be zero delay or a certain amount of cycles. If zero delay, they are ready for execution. Otherwise, they will be placed in waiting list until the amount of cycles passes.
  • 6. Process execution and Event Pools [From SystemC From the Groud Up]
  • 7. More on Kernel Operation • SystemC kernel enters the waiting state whenever it encounters an explicit wait(), or in some cases performs a return. – For zero delay, it is called a delta cycle delay. Related processes are moved to ready list. – For non-zero delay, processes are moved to the ready list when the time is advanced to the scheduled time is met. – When no process is to be executed for a triggered event, it simply returns to sc_main and finished.
  • 8. Use SC_THREAD as Process • An SC_THREAD is started once and only once. • An sc_thread takes control when it is started and returns (wait() inside of a loop) to the kernel or simply exits (return) after its execution. • When a SC_THREAD exits, it terminates forever, so, SC_THREAD usually contains an infinite loop.(while(1);) and at least one wait(). • An indirect method to invoke wait() is to call blocking methods like sc_fifo read or write.
  • 9. Trigger of an Event using .notify() • To cause an event to occur, .notify() can be used. • Usages: – name_of_event .notify(); //immediate notification – name_of_event .notify(SC_ZERO_TIME);//delayed notification – name_of_event .notify(time);//timed notification – notify(name_of_event) – notify(name_of_event, SC_ZERO_TIME); – notify(name_of_event, time); • Events can be cancelled by using .cancel(), but immediate events, which happen at the present notification time, cannot be cancelled.
  • 10. Effects of notify • When using notify(), kernel moves processes waiting for the from the wait pool into the ready list. • Notified Processes will execute only after all waiting processes have executed. • An sc_event may have no more than a single outstanding scheduled event, and only the nearest time notification is allowed.
  • 11. Dynamic Sensitivity of sc_thread using wait() • Wait() is used to suspend an sc_thread. • When wait() is executed, the state of the current sc_thread is saved and SystemC simulation kernel takes back its control. • Then, the kernel tries to activate the next ready process. • When the suspended thread resumes, its saved context is restored before continuing its execution.
  • 12. Syntax of wait() • • • • • wait(time); wait(name_of_event); wait(name_of_event1&name_of_event2&…); wait(timeout, name_of_event); wait(timeout, name_of_event1 | name_of_event2 | …….); • wait();// static sensitivity • …. And so on.
  • 13. Time_out() • Use time_out() to test a system sc_event event1, event2; …. wait(time, event1|event2); If(time_out()) break; …. If(event2) printf(…..); …….
  • 14. Simulation Scenarios in Different Perspects User Perceives Actual in SystemC Kernel [From SystemC From the Groud Up]
  • 15. Use SC_METHOD as Process • It is like a function call in C. Therefore, it is less suitable to modeling some behavior. • It runs completely and returns and may not suspend internally. Thus, wait() cannot be used here. • Based one sensitivity, it is called repeated by the simulation kernel. Therefore, it is more like Verilog always@() statement. • There are also implied waits such as read/write of sc_fifo, which should be avoided in sc_method.
  • 16. Using SC_METHOD and its Sensitivity • Syntax: – SC_METHOD(name_of_process); • Using an SC_METHOD, variables must be declared and initialized each time when it is invoked. • Sensitivity: the way it can be called repeatedly and synchronized with other processes – Dynamic – Static
  • 17. Dynamic Sensitivity of SC_METHOD • next_trigger() – – – – – next_trigger(time); next_trigger(event); next_trigger(name_of_event1&name_of_event2&…); next_trigger(timeout, name_of_event); next_trigger(timeout, name_of_event1 | name_of_event2 | …….); – next_trigger();// static sensitivity – …. And so on. • Looks exactly the same as wait();
  • 18. Using next_trigger() • It should be initialized and executed before the return of this SC_METHOD. • It is important to apply next_trigger() at every exit path in a SC_METHOD. Otherwise, it will never be invoked again. • To avoid the situation that a method is never called again, one can place a default next_trigger as its first statement. • It can be repeatedly called. Each time it is called, the previous ones are override.
  • 19. Processing Order of wait() and next_trigger() • wait(name_of_event1&name_of_event2&…)/nex t_trigger(name_of_event1&name_of_event2&…) ; – There is no knowing which event comes first: name_of_event1 or name_of_event2. It can be asserted that both events happen. • wait(name_of_event1|name_of_event2&…)/next _trigger(name_of_event1|name_of_event2&…); – It can be asserted that either events or both events happen. To know which event happen, additional code is required, like the time_out() example.
  • 20. Static Sensitivity • Static sensitivity is established during the elaboration stage and cannot be changed once it is established. • It applies to the most recent process registration. It is used when processes are handled for certain fixed events without implementing the related codes in the processes bodies. • Thread: wait();// static sensitivity • Method: next_trigger();// static sensitivity • Syntax: – sensitive << name_of_event1 [<< name_of_event2]; – sensitive (name_of_event, …);
  • 21. Example:using event & next_trigger • Hello_module: – Thread1:執行五次後會對thread2發出通知,執行 八次後會對method發出通知並將記數器歸零. – Thread2:執行兩次後會等待thread1的通知再繼 續進行;執行三次後會對method發出通知並將記 數器歸零. – Method:等待thread1及thread2的通知,並在 thread2通知執行過後,將只接受thread1的通知 (即thread2的通知將被忽略).
  • 22. Main.cpp #include <systemc.h> #include "hello_module.h" int sc_main(int argc, char* argv[]) { // signal declaration sc_clock clk("clk", 10, SC_NS, 0.5); // module declaration hello_module module0("hello_word"); // signal connection module0.clk(clk); // run simulation sc_start(1000, SC_NS); return 0; }
  • 23. Hello_module.h //Constructor SC_CTOR(hello_module) { count1 = 0; count2 = 0; #include <systemc.h> SC_MODULE(hello_module) { // signal declaration sc_in_clk clk; SC_THREAD(thread_func1); sensitive << clk.pos(); // fuction declaration void thread_func1(); void thread_func2(); void method_func(); SC_METHOD(method_func); sensitive << T1toM; sensitive << T2toM; SC_THREAD(thread_func2); sensitive << clk.pos(); } //event declaration sc_event T1toT2, T1toM, T2toM; int count1, count2; };
  • 24. Hello_moule.cpp(1/3) #include "hello_module.h" void hello_module::thread_func1() { while(1){ wait(); count1++; sc_time_stamp().print(); printf(" Thread1 : n"); if(count1 == 5){ printf(" Thread1 : T1toT2.notify() n"); T1toT2.notify(); } if(count1 == 8){ printf(" Thread1 : T1toM.notify() n"); T1toM.notify(); count1 = 0; }}}
  • 25. Hello_moule.cpp(2/3) void hello_module::thread_func2() { while(1){ wait(); count2++; sc_time_stamp().print(); printf(" Thread2 : n"); if(count2 == 2){ printf(" Thread2 : wait for T1.notify1 n"); wait(T1toT2); } if(count2 == 3){ printf(" Thread2 : T2toM.notify() n"); T2toM.notify(); count2 = 0; } } }
  • 26. Hello_moule.cpp(3/3) void hello_module::method_func() { if(clk){ sc_time_stamp().print(); printf(" Method : Hello Word! n"); //當T2toM叫起methodu第一次之後,T2toM將會失去作用. next_trigger(T1toM); } }
  • 27. Be Careful of Processing Order • One must be sure of the processing order of processes, because different processor orders may cause different results. • Sometimes, wrong process order may cause simulation errors though the program can be successfully compiled and no runtime error. • 書中figure 7-16 to 7-19舉了一個例子. 請大家看 一下, 然後寫一個簡單的例子, 當沒有figure7-17 中的wait(SC_ZERO_TIME)時, simulation結果會 有何不同呢?
  • 29. HW3 • 請設計以下四個模組: – 模組一: 系統一開始時讀入一文字檔(純英文),並讀入要搜尋的兩 個關鍵字。 – 模組二: 每個時脈時自模組一接收一個word,遇標點符號時丟棄 之。 – 模組三: 每當模組二接到一個非標點符號的word時,自模組二接收 此一word,並檢查是否為第一個關鍵字,若是,則計數器加一。 – 模組四: 每當模組二接到一個非標點符號的word時,自模組二接收 此一word,並檢查是否為第二個關鍵字,若是,則計數器加一。 – 文件結束時,模組三與模組數四通知模組一其個別之數目,模組 一印出數目後,讀入新的檔案。此處理直到該目錄下之檔案均被 檢查完後結束。 • 模組中必須含有method與thread,其他你可能需要再設計其他 模組來進行四個模組的控制,此一模組之設計則無限制。 • 模組間之資料傳輸此次不限定要用SystemC的預設介面 • 請用OpenESL作此一作業。2010/12/9,11:59PM繳交。