m physical modeling / IICSM

PHYSICS / ENGINEERING / COMPUTING

Embedded software and real-time systems

Derive timing, scheduling, sampling, buffering, fixed-point, and energy budgets, with twenty worked calculations.

Subject library · 51 guides · derivations & worked examples

Matter pathway: atom → solid → liquid → gas → plasma. Quantum mechanics and quantum field theory provide foundations across the pathway; they are not additional phases. This is a connected modeling route, not a universal heating curve. Actual phases depend on pressure, composition, and kinetics.

1. Clocks and execution

Definitions & inputs. fclk clock frequency, Ncycles executed cycles, C execution time, T task period.

  1. Convert clock counts into elapsed time.

    ttick=1/fclk,C=Ncycles/fclkt_{tick}=1/f_{clk},\quad C=N_{cycles}/f_{clk}
  2. Add each periodic task’s required processor fraction.

    U=∑iCi/TiU=\sum_i C_i/T_i
  3. This sufficient rate-monotonic bound assumes independent preemptible periodic tasks with deadlines equal to periods.

    U≤n(21/n−1)U\le n(2^{1/n}-1)

Interpretation. Exceeding the bound does not prove failure; use response-time analysis.

↑ Return to definitions and contents

2. Response time and deadlines

Definitions & inputs. Ci execution, Bi blocking, Ti period, hp(i) higher-priority tasks, Ri response time.

  1. Start with the task’s own demand plus blocking.

    Ri(0)=Ci+BiR_i^{(0)}=C_i+B_i
  2. Count interfering releases within the tentative response window.

    Ri(k+1)=Ci+Bi+∑j∈hp(i)⌈Ri(k)/Tj⌉CjR_i^{(k+1)}=C_i+B_i+\sum_{j\in hp(i)}\lceil R_i^{(k)}/T_j\rceil C_j
  3. Stop at a fixed point or a missed deadline.

    Ri≤DiR_i\le D_i

Interpretation. Interrupt service and context overhead must be included consistently.

↑ Return to definitions and contents

3. Data movement and representation

Definitions & inputs. fs sample rate, b bits/sample, Δ quantizer step, x represented value.

  1. Sampling defines the stream rate; integrate over a consumer pause for buffer bytes.

    Rb=fsb,B=Rbtgap/8R_b=f_sb,\quad B=R_b t_{gap}/8
  2. Divide the input span among N-bit bins and round to the nearest bin.

    Δ=VFS/2N,∣eq∣≤Δ/2\Delta=V_{FS}/2^N,\quad |e_q|\le\Delta/2
  3. Fixed-point integer q represents a physical value with F fractional bits.

    x=q2−Fx=q2^{-F}

Interpretation. Guard against endpoint clipping, rounding conventions, and arithmetic overflow.

↑ Return to definitions and contents

4. Energy and duty cycles

Definitions & inputs. Da active fraction, Ia and Is active/sleep currents, V supply voltage.

  1. Time-weight the mode currents.

    Iavg=DaIa+(1−Da)IsI_{avg}=D_aI_a+(1-D_a)I_s
  2. Integrate approximately constant power over the observation interval.

    E=VIavgtE=VI_{avg}t
  3. Divide usable capacity by average current using compatible hour units.

    tlife=Qbattery/Iavgt_{life}=Q_{battery}/I_{avg}

Interpretation. Radio bursts, self-discharge, voltage conversion, and wakeup latency can dominate.

↑ Return to definitions and contents

Graphical worked example

20 mA active and 0.1 mA sleep; wakeup energy and converter losses omitted. X axis: Active duty fraction (dimensionless). Y axis: Average current (mA).
20 mA active and 0.1 mA sleep; wakeup energy and converter losses omitted. Related worked calculation · Download SVG · Plot data

Twenty worked examples

Open a problem to see its defined inputs, assumptions, equation, numerical substitution, result, and interpretation. Values are illustrative analytical exercises.

Example 01. Clock tick

Definitions & inputs. Clock 48 MHz.

  1. Choose the governing model and isolate the requested quantity.

    t=1/ft=1/f
  2. Insert the stated inputs in consistent units or the explicitly defined normalized units.

    t=1/(48×106)t=1/(48\times10^6)
  3. Evaluate the expression; the result uses the units shown.

    Result=20.83333 ns\mathrm{Result}=20.83333\ {\rm ns}

Interpretation. A clock tick is not necessarily a complete instruction.

↑ Return to definitions and contents
Example 02. Execution duration

Definitions & inputs. 2400 cycles at 48 MHz.

  1. Choose the governing model and isolate the requested quantity.

    C=N/fC=N/f
  2. Insert the stated inputs in consistent units or the explicitly defined normalized units.

    C=2400/(48×106)C=2400/(48\times10^6)
  3. Evaluate the expression; the result uses the units shown.

    Result=50 μs\mathrm{Result}=50\ {\rm \mu s}

Interpretation. Memory stalls must already be included in the count.

↑ Return to definitions and contents
Example 03. Timer prescaler

Definitions & inputs. Source 48 MHz, desired timer tick 1 MHz.

  1. Choose the governing model and isolate the requested quantity.

    P=fsource/ftickP=f_{source}/f_{tick}
  2. Insert the stated inputs in consistent units or the explicitly defined normalized units.

    P=48/1P=48/1
  3. Evaluate the expression; the result uses the units shown.

    Result=48 \mathrm{Result}=48\ {}

Interpretation. Some timer registers encode P−1 rather than P.

↑ Return to definitions and contents
Example 04. Timer compare count

Definitions & inputs. Tick 1 μs, interval 2 ms.

  1. Choose the governing model and isolate the requested quantity.

    N=t/ttickN=t/t_{tick}
  2. Insert the stated inputs in consistent units or the explicitly defined normalized units.

    N=2000/1N=2000/1
  3. Evaluate the expression; the result uses the units shown.

    Result=2000 ticks\mathrm{Result}=2000\ {\rm ticks}

Interpretation. Check whether the hardware counts inclusively from zero.

↑ Return to definitions and contents
Example 05. Task utilization

Definitions & inputs. C1=1 ms,T1=5 ms; C2=2 ms,T2=10 ms.

  1. Choose the governing model and isolate the requested quantity.

    U=C1/T1+C2/T2U=C_1/T_1+C_2/T_2
  2. Insert the stated inputs in consistent units or the explicitly defined normalized units.

    U=1/5+2/10U=1/5+2/10
  3. Evaluate the expression; the result uses the units shown.

    Result=0.4 \mathrm{Result}=0.4\ {}

Interpretation. Forty percent excludes unlisted interrupt and kernel overhead.

↑ Return to definitions and contents
Example 06. Three-task sufficient bound

Definitions & inputs. n=3 independent periodic tasks under rate-monotonic scheduling.

  1. Choose the governing model and isolate the requested quantity.

    Ub=n(21/n−1)U_b=n(2^{1/n}-1)
  2. Insert the stated inputs in consistent units or the explicitly defined normalized units.

    Ub=3(21/3−1)U_b=3(2^{1/3}-1)
  3. Evaluate the expression; the result uses the units shown.

    Result=0.7797631 \mathrm{Result}=0.7797631\ {}

Interpretation. This is sufficient, not necessary, under the stated ideal assumptions.

↑ Return to definitions and contents
Example 07. Low-priority response time

Definitions & inputs. Low task C=2 ms; high task C=1 ms,T=5 ms; B=0.

  1. Choose the governing model and isolate the requested quantity.

    R=2+⌈R/5⌉R=2+\lceil R/5\rceil
  2. Insert the stated inputs in consistent units or the explicitly defined normalized units.

    R(0)=2, R(1)=3, R(2)=3R^{(0)}=2,\ R^{(1)}=3,\ R^{(2)}=3
  3. Evaluate the expression; the result uses the units shown.

    Result=3 ms\mathrm{Result}=3\ {\rm ms}

Interpretation. The fixed point is 3 ms; compare against the low task deadline.

↑ Return to definitions and contents
Example 08. Deadline slack

Definitions & inputs. Deadline 10 ms, worst-case response 7 ms.

  1. Choose the governing model and isolate the requested quantity.

    S=D−RS=D-R
  2. Insert the stated inputs in consistent units or the explicitly defined normalized units.

    S=10−7S=10-7
  3. Evaluate the expression; the result uses the units shown.

    Result=3 ms\mathrm{Result}=3\ {\rm ms}

Interpretation. Slack is meaningful only if the response bound is justified.

↑ Return to definitions and contents
Example 09. Interrupt overhead fraction

Definitions & inputs. 10000 interrupts/s, handler 2 μs each.

  1. Choose the governing model and isolate the requested quantity.

    U=firqCirqU=f_{irq}C_{irq}
  2. Insert the stated inputs in consistent units or the explicitly defined normalized units.

    U=104(2×10−6)U=10^4(2\times10^{-6})
  3. Evaluate the expression; the result uses the units shown.

    Result=0.02 \mathrm{Result}=0.02\ {}

Interpretation. Entry, exit, and nesting costs must be included in handler time.

↑ Return to definitions and contents
Example 10. ADC voltage step

Definitions & inputs. 12-bit converter, full-scale span 3.3 V.

  1. Choose the governing model and isolate the requested quantity.

    Δ=VFS/212\Delta=V_{FS}/2^{12}
  2. Insert the stated inputs in consistent units or the explicitly defined normalized units.

    Δ=3.3/4096\Delta=3.3/4096
  3. Evaluate the expression; the result uses the units shown.

    Result=0.0008056641 V\mathrm{Result}=0.0008056641\ {\rm V}

Interpretation. This is quantization step, not total accuracy.

↑ Return to definitions and contents
Example 11. Quantization error bound

Definitions & inputs. Step 0.8 mV; nearest rounding.

  1. Choose the governing model and isolate the requested quantity.

    ∣e∣max=Δ/2|e|_{max}=\Delta/2
  2. Insert the stated inputs in consistent units or the explicitly defined normalized units.

    ∣e∣max=0.8/2|e|_{max}=0.8/2
  3. Evaluate the expression; the result uses the units shown.

    Result=0.4 mV\mathrm{Result}=0.4\ {\rm mV}

Interpretation. Noise and calibration error are additional effects.

↑ Return to definitions and contents
Example 12. Sampling data rate

Definitions & inputs. 1000 samples/s, 16 bits/sample.

  1. Choose the governing model and isolate the requested quantity.

    R=fsbR=f_sb
  2. Insert the stated inputs in consistent units or the explicitly defined normalized units.

    R=1000(16)R=1000(16)
  3. Evaluate the expression; the result uses the units shown.

    Result=16000 bit s−1\mathrm{Result}=16000\ {\rm bit\,s}^{-1}

Interpretation. Packet headers are not included.

↑ Return to definitions and contents
Example 13. Buffer for a pause

Definitions & inputs. Producer 2000 bytes/s; consumer unavailable 0.25 s; empty initial buffer.

  1. Choose the governing model and isolate the requested quantity.

    B=rtB=rt
  2. Insert the stated inputs in consistent units or the explicitly defined normalized units.

    B=2000(0.25)B=2000(0.25)
  3. Evaluate the expression; the result uses the units shown.

    Result=500 bytes\mathrm{Result}=500\ {\rm bytes}

Interpretation. Add margin for bursts and pre-existing queued data.

↑ Return to definitions and contents
Example 14. UART payload throughput

Definitions & inputs. 115200 bit/s, 8-N-1 framing: 10 transmitted bits per byte.

  1. Choose the governing model and isolate the requested quantity.

    r=R/10r=R/10
  2. Insert the stated inputs in consistent units or the explicitly defined normalized units.

    r=115200/10r=115200/10
  3. Evaluate the expression; the result uses the units shown.

    Result=11520 bytes s−1\mathrm{Result}=11520\ {\rm bytes\,s}^{-1}

Interpretation. This excludes any protocol overhead or idle gaps.

↑ Return to definitions and contents
Example 15. SPI transfer duration

Definitions & inputs. 256 bytes at 8 Mbit/s; no gaps.

  1. Choose the governing model and isolate the requested quantity.

    t=8B/Rt=8B/R
  2. Insert the stated inputs in consistent units or the explicitly defined normalized units.

    t=8(256)/(8×106)t=8(256)/(8\times10^6)
  3. Evaluate the expression; the result uses the units shown.

    Result=256 μs\mathrm{Result}=256\ {\rm \mu s}

Interpretation. Chip-select setup and software latency add time.

↑ Return to definitions and contents
Example 16. Fixed-point decode

Definitions & inputs. Stored integer q=384, F=8 fractional bits.

  1. Choose the governing model and isolate the requested quantity.

    x=q2−Fx=q2^{-F}
  2. Insert the stated inputs in consistent units or the explicitly defined normalized units.

    x=384/256x=384/256
  3. Evaluate the expression; the result uses the units shown.

    Result=1.5 \mathrm{Result}=1.5\ {}

Interpretation. Signed range depends on total word length.

↑ Return to definitions and contents
Example 17. Unsigned counter wrap

Definitions & inputs. 16-bit counter increments at 1 kHz.

  1. Choose the governing model and isolate the requested quantity.

    t=216/ft=2^{16}/f
  2. Insert the stated inputs in consistent units or the explicitly defined normalized units.

    t=65536/1000t=65536/1000
  3. Evaluate the expression; the result uses the units shown.

    Result=65.536 s\mathrm{Result}=65.536\ {\rm s}

Interpretation. Use modular subtraction only within a documented wrap interval.

↑ Return to definitions and contents
Example 18. Average current

Definitions & inputs. Active 20 mA for 10% time; sleep 0.1 mA.

  1. Choose the governing model and isolate the requested quantity.

    I=DIa+(1−D)IsI=DI_a+(1-D)I_s
  2. Insert the stated inputs in consistent units or the explicitly defined normalized units.

    I=0.1(20)+0.9(0.1)I=0.1(20)+0.9(0.1)
  3. Evaluate the expression; the result uses the units shown.

    Result=2.09 mA\mathrm{Result}=2.09\ {\rm mA}

Interpretation. Transition energy and radio peaks are omitted.

↑ Return to definitions and contents
Example 19. Ideal battery lifetime

Definitions & inputs. Usable capacity 1000 mAh, average current 2 mA.

  1. Choose the governing model and isolate the requested quantity.

    t=Q/It=Q/I
  2. Insert the stated inputs in consistent units or the explicitly defined normalized units.

    t=1000/2t=1000/2
  3. Evaluate the expression; the result uses the units shown.

    Result=500 h\mathrm{Result}=500\ {\rm h}

Interpretation. The usable capacity has to reflect load and environment.

↑ Return to definitions and contents
Example 20. Watchdog timing margin

Definitions & inputs. Timeout 100 ms; maximum valid service gap 70 ms.

  1. Choose the governing model and isolate the requested quantity.

    M=ttimeout−tgapM=t_{timeout}-t_{gap}
  2. Insert the stated inputs in consistent units or the explicitly defined normalized units.

    M=100−70M=100-70
  3. Evaluate the expression; the result uses the units shown.

    Result=30 ms\mathrm{Result}=30\ {\rm ms}

Interpretation. A watchdog detects missed service, not all forms of incorrect software execution.

↑ Return to definitions and contents

Symbols and units

Each derivation and problem defines its own symbols and inputs. Symbols may be reused with different meanings in other subjects. Keep units consistent, retain sufficient precision during calculation, and apply the stated validity limits.