posix modeling in systemc - asp-dac 1995 · •“wait”and “notify”to stop and resume the...

25
POSIX modeling in SystemC POSIX modeling in SystemC Hector Hector Posadas Posadas , , Jes Jesús Á damez damez , Pablo , Pablo Sá nchez nchez & & Eugenio Villar Eugenio Villar University of Cantabria University of Cantabria Francisco Francisco Blasco Blasco DS2 DS2

Upload: others

Post on 18-Aug-2020

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: POSIX modeling in SystemC - ASP-DAC 1995 · •“wait”and “notify”to stop and resume the threads –Needed to model the scheduling and synchronization POSIX modeling. Concurrency

POSIX modeling in SystemCPOSIX modeling in SystemC

Hector Hector PosadasPosadas, , JesJesúúss ÁÁdamezdamez, Pablo , Pablo SSááncheznchez & & Eugenio VillarEugenio Villar

University of CantabriaUniversity of Cantabria

Francisco Francisco BlascoBlascoDS2DS2

Page 2: POSIX modeling in SystemC - ASP-DAC 1995 · •“wait”and “notify”to stop and resume the threads –Needed to model the scheduling and synchronization POSIX modeling. Concurrency

OutlineOutline

MotivationPOSIX modeling– Functionality– Timed simulation

ResultsConclusions

Page 3: POSIX modeling in SystemC - ASP-DAC 1995 · •“wait”and “notify”to stop and resume the threads –Needed to model the scheduling and synchronization POSIX modeling. Concurrency

•New SystemC framework -SW and HW refined

together

Performance& functionalverification

Architecturalmapping SystemC

HW/SWsynthesis

ITRS: Design flow evolutionITRS: Design flow evolutionMotivation

Page 4: POSIX modeling in SystemC - ASP-DAC 1995 · •“wait”and “notify”to stop and resume the threads –Needed to model the scheduling and synchronization POSIX modeling. Concurrency

SW modeling nowadaysSW modeling nowadays

Current industrial techniques not adequate for HW/SW co-design flow– Commercial RTOS simulators

• Functional but untimed models• Difficult HW integration• Limited performance estimations

– ISS is too slow for complex systems• Refiment process slow

Motivation

Our approach

Page 5: POSIX modeling in SystemC - ASP-DAC 1995 · •“wait”and “notify”to stop and resume the threads –Needed to model the scheduling and synchronization POSIX modeling. Concurrency

HW & SW modeling in SystemCHW & SW modeling in SystemC

SystemC used for HW design

SystemC lacks a standard model of SW– Execution of SW code is untimed– Actual task execution order difficult to model

in SystemC• Scheduling capabilities cannot be directly modeled

– Refined SW code usually includes system calls• SystemC does not provide an RTOS API

Motivation

Page 6: POSIX modeling in SystemC - ASP-DAC 1995 · •“wait”and “notify”to stop and resume the threads –Needed to model the scheduling and synchronization POSIX modeling. Concurrency

State of the artState of the art

Abstract RTOS models in SpecC and SystemC– Specific RTOS functions

• Simulation code not valid for implementation– Low-level, timing behavior is not adequately

modeled• “wait” statements in predefined points

– Time-slicing– Preemption– Interrupts…

• Communication issues– Priority inheritance

Motivation

Page 7: POSIX modeling in SystemC - ASP-DAC 1995 · •“wait”and “notify”to stop and resume the threads –Needed to model the scheduling and synchronization POSIX modeling. Concurrency

SW modeling in SystemCSW modeling in SystemC

A complete SystemC RTOS model is required– All common RTOS features for optimum

refinement• Scheduling & preemption • Communication & synchronization• Timing functions: clocks, timers• …

– Refined SW has to be directly implementable• Real API

POSIX modeling

Page 8: POSIX modeling in SystemC - ASP-DAC 1995 · •“wait”and “notify”to stop and resume the threads –Needed to model the scheduling and synchronization POSIX modeling. Concurrency

SW modeling in SystemCSW modeling in SystemCComplete, standard RTOS API required– POSIX is the most common RTOS API– Contains all elements required for optimum

refinement

A time estimation technique required– Not part of this work– PERFidy used [1]– Any other dynamic technique possible

POSIX modeling

[1] H. Posadas, P. Sanchez, E. Villar, F.Blasco:”System-level performance estimation in SystemC”, DATE’04

Page 9: POSIX modeling in SystemC - ASP-DAC 1995 · •“wait”and “notify”to stop and resume the threads –Needed to model the scheduling and synchronization POSIX modeling. Concurrency

SW modelingSW modeling

POSIX API

RTOS

PROCESSOR

... Application SW

Task 1 Task n

POSIX modeling

POSIX API

POSIX model

SystemC

... Application SW

Task 1 Task n

Modeling

Page 10: POSIX modeling in SystemC - ASP-DAC 1995 · •“wait”and “notify”to stop and resume the threads –Needed to model the scheduling and synchronization POSIX modeling. Concurrency

POSIX standardPOSIX standard

Concurrency

Scheduling

Timing

Communication & synchronization

Channels I/O Sockets Signals Peripherals

Matemathical Strings

Memory

POSIX

SystemC Host RTOS

POSIX modeling

Specific drivers required

Page 11: POSIX modeling in SystemC - ASP-DAC 1995 · •“wait”and “notify”to stop and resume the threads –Needed to model the scheduling and synchronization POSIX modeling. Concurrency

Host RTOS facilitiesHost RTOS facilities

SystemC allows using host pthreads to implement SC_THREADs

Most POSIX features cannot be modeled using host RTOS– The SystemC simulation has only one execution flow– SystemC is one host process

• Signals, waitpid, fork, etc cannot be modeled– Clocks, timers, timeouts depends on host simulation

time, not on estimated time for the target platform

POSIX modeling

Page 12: POSIX modeling in SystemC - ASP-DAC 1995 · •“wait”and “notify”to stop and resume the threads –Needed to model the scheduling and synchronization POSIX modeling. Concurrency

SystemC facilitiesSystemC facilities

The RTOS model extends the SystemC kernel– The kernel is not modified

• Ensures compatibility with different SystemC versions

– A reduced set of SystemC elements is needed• SC_THREAD to provide concurrency• “wait” and “ notify” to stop and resume the threads

– Needed to model the scheduling and synchronization

POSIX modeling

Page 13: POSIX modeling in SystemC - ASP-DAC 1995 · •“wait”and “notify”to stop and resume the threads –Needed to model the scheduling and synchronization POSIX modeling. Concurrency

Concurrency modelingConcurrency modeling

Parallelism– SC_THREAD– Threads and processes

• Limitations when modeling separate memory spaces

– Dynamic creation of threads and processes

All SC_THREADs runs in parallel– Tasks in the same processor cannot run in

parallel• Scheduling

POSIX modeling

Page 14: POSIX modeling in SystemC - ASP-DAC 1995 · •“wait”and “notify”to stop and resume the threads –Needed to model the scheduling and synchronization POSIX modeling. Concurrency

Scheduling in POSIXScheduling in POSIX

POSIX defines several policies– Round Robin, FIFO, Sporadic Server

• Different exit procedure• FIFO

– process stopped in a synchronization point

• RR and SS– a time slice is finished or a synchronization point is

reached

Use of priorities

POSIX modeling

Page 15: POSIX modeling in SystemC - ASP-DAC 1995 · •“wait”and “notify”to stop and resume the threads –Needed to model the scheduling and synchronization POSIX modeling. Concurrency

Scheduling Scheduling modelingmodelingScheduling modeled with “wait” and “ notify”functions– Only the thread with higher priority is not blocked – Scheduler execution when running thread releases the

processor

Preemption has to be consideredTime estimation tool is required– Time-slice based policies– Time events (sleeps, timeouts, timers)

POSIX modeling

Page 16: POSIX modeling in SystemC - ASP-DAC 1995 · •“wait”and “notify”to stop and resume the threads –Needed to model the scheduling and synchronization POSIX modeling. Concurrency

SW modelingSW modeling

POSIX modeling

POSIX API

POSIX model

SystemC

... Application SW

Task 1 Task n

TIME MANAGER TIME ESTIMATION TOOL

Page 17: POSIX modeling in SystemC - ASP-DAC 1995 · •“wait”and “notify”to stop and resume the threads –Needed to model the scheduling and synchronization POSIX modeling. Concurrency

ΔT= 40

ΔT= 20

ΔT= 20

PreemptionPreemption exampleexample

POSIX modeling

ΔT= 40

Time (us)

Task 1Priority 1

Task 2Priority 2

T= 0

T=20

T=30

T=40

T=50

T=10

Simulation time

Estimation time

ΔT= 20

Expectedpreemption

Events

Predictable:Timeout expiration T=20us

T=70

T=80

T=60

T=90 ΔT= 10

Unpredictable:Hardware interrupt T=65us

Delayed preemption

Codeexecution

Time annotation

Unexpected preemption

ΔT= 10

Delayedpreemption

B=A-6;C=A+B;B*=2;

A=C/B;

D=C+1;

Task 1 Time estimation tool

Time: 10 ns20 ns55 ns20 us

Page 18: POSIX modeling in SystemC - ASP-DAC 1995 · •“wait”and “notify”to stop and resume the threads –Needed to model the scheduling and synchronization POSIX modeling. Concurrency

Communication & synchronizationCommunication & synchronization

Required a complete set of communication and synchronization mechanisms for SW refinement – Mutexes, semaphores, conditional variables, message

queues, etc• Wide range of options: Priority inheritance• “wait” and “ notify” functions of SystemC are used to model

synchronization

– Asynchronous events: POSIX Signals• An specific SC_THREAD is required to execute signal

handlers– signal handling can require a temporal new thread

POSIX modeling

Page 19: POSIX modeling in SystemC - ASP-DAC 1995 · •“wait”and “notify”to stop and resume the threads –Needed to model the scheduling and synchronization POSIX modeling. Concurrency

Clocks and timersClocks and timers

POSIX standard defines several clocks– Real-time, monotonic

• Are modeled with the SystemC time control• Timers, alarms & sleeps can be modeled with “wait(t)”

– Thread clocks, process clocks• The clock values are updated with the time

estimation• A new SC_THREAD is required to execute events

depending on this clocks (timers)

POSIX modeling

Page 20: POSIX modeling in SystemC - ASP-DAC 1995 · •“wait”and “notify”to stop and resume the threads –Needed to model the scheduling and synchronization POSIX modeling. Concurrency

ResultsResultsThe POSIX model has been used to simulate a GSM coder– ETSI - EN 301 245 – 13.500 code lines– Manually parallelized

• 9 concurrent processesResults– Verify the RTOS model with the real target RTOS– Time estimation errors compared

• SystemC (without RTOS model) vs. time in target platform• SystemC + POSIX model vs. time in target platform

Page 21: POSIX modeling in SystemC - ASP-DAC 1995 · •“wait”and “notify”to stop and resume the threads –Needed to model the scheduling and synchronization POSIX modeling. Concurrency

ResultsResults

The error is lower when considering the effect of the RTOS – With the same estimation technique

Thread SystemC (%) POSIX (%)pre_filtering 3.45 2.41

homing_frame_test 13.67 0.88frame_lsp_func 4.51 0.45

frame_int_tol_fun 0.94 0.36subframe_coder_fun 3.04 0.23

serializer_fun 6.72 6.36vad_comp_fun 9.36 3.34

CN_encoder_fun 7.45 5.33sid_encoding_fun 12.18 7.29

RTOS 1.84

Page 22: POSIX modeling in SystemC - ASP-DAC 1995 · •“wait”and “notify”to stop and resume the threads –Needed to model the scheduling and synchronization POSIX modeling. Concurrency

ResultsResults

Overhead of RTOS model is worthless respect gain with ISS

SC (ms) SC + P (ms) ISS (ms)Simulation

time 1,07 1,56 124

Page 23: POSIX modeling in SystemC - ASP-DAC 1995 · •“wait”and “notify”to stop and resume the threads –Needed to model the scheduling and synchronization POSIX modeling. Concurrency

ConclusionsConclusions

Current version of SystemC can be extended to model a complex RTOS– SW refinement can be done in SystemC

SW refinement over SystemC requires a complete RTOS model– Standard API– All features present in target RTOS

Page 24: POSIX modeling in SystemC - ASP-DAC 1995 · •“wait”and “notify”to stop and resume the threads –Needed to model the scheduling and synchronization POSIX modeling. Concurrency

ConclusionsConclusions

Close link Estimation tool – RTOS model– Modeling of time-slices & time events– RTOS model requires time estimations

(process & thread clocks)– Estimation results better with RTOS model

High-level modeling and timed simulation of application SW is possible at source code– Fast estimations with enough accuracy

Page 25: POSIX modeling in SystemC - ASP-DAC 1995 · •“wait”and “notify”to stop and resume the threads –Needed to model the scheduling and synchronization POSIX modeling. Concurrency

ThankThank YouYou !!