COTS Challenges for Embedded Systems - PowerPoint PPT Presentation

1 / 4
About This Presentation
Title:

COTS Challenges for Embedded Systems

Description:

E81 CSE 532S: Advanced Multi-Paradigm Software Development Advanced C++11 Thread Management Chris Gill Department of Computer Science and Engineering – PowerPoint PPT presentation

Number of Views:37
Avg rating:3.0/5.0
Slides: 5
Provided by: dsch7
Category:

less

Transcript and Presenter's Notes

Title: COTS Challenges for Embedded Systems


1
E81 CSE 532S Advanced Multi-Paradigm Software
Development
Advanced C11 Thread Management
Chris Gill Department of Computer Science and
Engineering Washington University in St.
Louis cdgill_at_cs.wustl.edu
2
Thread Pools
  • Simplest version
  • A thread per core, all run a common worker thread
    function
  • Waiting for tasks to complete
  • Promises and futures give rendezvous with work
    completion
  • Could also post work results on an active
    objects queue, which also may help avoid cache
    ping-pong
  • Futures also help with exception safety, e.g., a
    thrown exception propagates to thread that calls
    get on the future
  • Granularity of work is another key design
    decision
  • Too small and the overhead of managing the work
    adds up
  • To coarse and responsiveness, concurrency, may
    suffer
  • Work stealing lets idle threads relieve busy ones
  • May need to hand off promise as well as work, etc.

3
Interrupting Threads (Part I)
  • Thread with interruption point is (cleanly)
    interruptible
  • Another thread can set a flag that it will notice
    and then exit
  • Clever use of lambdas, promises, move semantics
    lets a thread-local interrupt flag be managed
    (see listing 9.9)
  • Need to be careful to avoid dangling pointers on
    thread exit
  • For simple cases, detecting interruption may be
    trivial
  • E.g., event loop with interruption point checked
    each time
  • For condition variables interruption is more
    complex
  • E.g., using the guard idiom to avoid exception
    hazards
  • E.g., waiting with a timeout (and handling
    spurious wakes)
  • Can eliminate spurious wakes with a scheme based
    on a custom lock and a condition_variable_any
    (listing 9.12)

4
Interrupting Threads (Part II)
  • Unlike condition variable waits, thread
    interruption with other blocking calls goes back
    to timed waiting
  • No access to internals of locking and unlocking
    semantics
  • Best you can do is unblock and check frequently
    (with interval chosen to balance overhead and
    responsiveness)
  • Handling interruptions
  • Can use standard exception handling in
    interrupted thread
  • Can use promises and futures between threads to
    propagate
  • Put a catch block in the wrapper that initializes
    the interrupt flag, so uncaught exception doesnt
    end the entire program
  • Can combine interruption and joining with threads
  • E.g., to stop background threads and wait for
    them to end
Write a Comment
User Comments (0)
About PowerShow.com