stem/IOT/OS/Composition.md
Andy Pack b96482abd3 vault backup: 2023-12-28 11:35:06
Affected files:
.obsidian/graph.json
.obsidian/workspace-mobile.json
.obsidian/workspace.json
Politcs/America/94 Crime Bill.md
Politcs/America/Black.md
Politcs/America/Presidents.md
Politcs/BLM.md
Politcs/British/Prime Ministers.md
Politcs/British/Tory.md
Politcs/Compass.md
Politcs/Fascism.md
Politcs/Labour Laws.md
Politcs/Neoliberalism/Neoliberalism.md
Politcs/Neoliberalism/Thatcher.md
Politcs/Now.md
Politcs/Socialism.md
STEM/IOT/Cyber-Physical Systems.md
STEM/IOT/Networking/Networking.md
STEM/IOT/OS/Composition.md
STEM/IOT/OS/Contiki.md
STEM/IOT/OS/OS.md
STEM/IOT/Software Services.md
2023-12-28 11:35:06 +00:00

55 lines
1.5 KiB
Markdown

---
tags:
- dev
- iot
---
# Threading
*Smallest sequence of programmed instructions that can be managed independently by a [scheduler](https://en.wikipedia.org/wiki/Scheduling_(computing))*
From <[https://en.wikipedia.org/wiki/Thread_(computing)](https://en.wikipedia.org/wiki/Thread_(computing))>
- Instructions run independently by scheduler
- Single address space
- One thread blocked for I/O
- Tasks run in other threads
- Need locks and mutexes
- Coordination between threads
- Complicated
- Deadlocks
# Protothreads
- Lightweight
- Stack-less
- Interruptible tasks for event-based
- Conditional blocking statement
- Blocks until given statement is true
- Use timer to manage
- Invoked whenever process receives message from another process or timer
# Events
*Action or occurrence recognized by software, often originating asynchronously from the external environment, that may be [handled](https://en.wikipedia.org/wiki/Event_handler) by the software*
From <[https://en.wikipedia.org/wiki/Event_(computing)](https://en.wikipedia.org/wiki/Event_(computing))>
- Event loop
- Waits for events
- Inputs
- On event
- Collects info
- Dispatches to call-back
- Register handlers with OS scheduler
- Kernel usually runs loop to poll for events
- Blocking operation
- Register call-back
- Return control to scheduler
# Radio Sleep
- Energy efficiency
- Congestion
## Event-based
![](../../img/iot-event-based.png)
## Thread-based
![](../../img/iot-thread-based.png)
- Less complex
- Faster
- Pointer-based