☆★☆2017.08.10 작성☆★☆
https://www.zephyrproject.org/
https://github.com/zephyrproject-rtos/zephyr
**What is Zephyr Project?**
The Zephyr™ Project, is a Linux Foundation hosted Collaboration Project, an open source collaborative effort uniting leaders from across the industry to build a best-in-breed small, scalable, real-time operating system (RTOS) optimized for resource constrained devices, across multiple architectures. The Zephyr Project’s goal is to establish a neutral project where silicon vendors, OEMs, ODMs, ISVs, and OSVs can contribute technology to reduce the cost and accelerate time to market for developing the billions of devices that will make up the majority of the Internet of Things.
Introducing Zephyr
· Zephyr OS is based on a *small-footprint kernel designed for use on **resource-constrained systems
- simple embedded environmental sensors
- LED wearables to sophisticated smart watches and IoT wireless gateways
*small-footprint : memory 적게 차지
**resource-constrained system : 자원제약시스템, 컴퓨터 자원이 제한되어 있는 system
ex) 물리적으로 hardware 제약 / memory를 추가한다거나 graphic을 추가할수 x
· Zephyr kernel supports ARM Cortex-M, Intel x86, ARC, NIOS II and RISC V
· Distinguishing Features
- Single address-space : application code와 kernel code가 하나의 공유 주소 공간에서 실행
- Highly configurable : application이 필요한 만큼만 사용하거나 size 같은 것 조절 가능
- Compile-time resource definition : system resource가 compile-time에 정의(장점: code size↓, performance ↑)
- Minimal error checking : 추가적으로 option으로 주어지는 error-checking이 디버깅에 도움
(장점: code size↓, performance ↑)
- Extensive suite for serviced
: Multi-threading, Interrupt, Memory Allocation, Inter-thread Synchronization,
Inter-thread Data Passing, Power Management
Zephyr Kernel Primer
1. Threads
· Scheduling ☆☆☆
- determines which thread is allowed to execute at any point in time this; current thread
- Thread Priorities(integer value, negative or non-negative)
- Cooperative thread(negative priority), Preemptible thread(non-negative priority)
- CONFIG_NUM_COOP_PRIORITIES, CONFIG_NUM_PREEMPT_PRIORITIES
- Scheduling Algorithm
- selects the highest priority ready thread to be the current thread
- CONFIG_TIMESLICING, CONFIG_TIMESLICE_SIZE, CONFIG_TIMESLICE_PRIORITY
- Suggested Uses
- cooperative threads for device drivers and other performance-critical work
- preemptive threads to give priority to time-sensitive processing over less time-sensitive processing
☆ timeslice 안에서 preemptive가 되는가?
☆ timeslice는 동적으로 바뀔 수 있는가?
☆ 소스코드 내에서 prio_ceiling(priority ceiling)이 무엇인지?
☆ cooperative thread와 preemptible thread 중 어떤 thread가 우선순위가 높은가?
☆ CONFIG_NUM_COOP_PRIORITIES와 CONFIG_NUM_PREEMPT_PRIORITIES의 default 범위는?(~256??)
· System Thread
- system thread kernel spawns automatically during system initialization
- Main thread : kernel이 초기 설정되면 main에서 call
- Use the main thread to perform thread-based processing in an application that only requires a single thread, rather than defining an additional application-specific thread
- Idle thread : system에서 work가 아무것도 일어나지 않을 떄 발생
· Workqueue Thread
- kernel object that uses a dedicated thread to process work items in FIFO
☆ workqueue thread는 어떻게 사용되는가?(예제)
☆ 왜 따로 workqueue thread 라는 이름을 붙였나?
2. Timing
· Kernel Clocks
- foundation for all of time-based services
- 32bit hardware clock
- high precision counter that tracks time in unspecified units called cycle
- 64bit system clock
- counter that tracks the number of ticks that have elapsed since the kernel was initialized
- CONFIG_SYS_CLOCK_TICKS_PER_SEC
☆ tick의 변수는 무엇인가?(범위는?)
· Timers
- kernel object that measures the passage of time using the kernel's system clock
- timer 요소 : duration, period, expiry function, stop function, status value
- use a timer to initiate an asynchronous operation after a specified amount of time
3. Other Services
· CPU Idling
- Making the CPU idle causes the kernel to pause all operations until an event, normally an interrupt, wakes up the CPU
- Making the CPU idle : k_cpu_idle()
- Use only when a thread is only responsible for idling the CPU, i.e. not doing any real work
- Making the CPU idle in an atomic fashion : k_cpu_atomic_idle()
- Use when a thread has to do some real work in addition to idling the CPU to wait for an event.
☆ atomic fashion이란 무엇인가?
☆ 소스코드 중에서 k_sem_take((&my_sem, k_NO_WAIT)==0), k_cpu_atomic_idle(key) 가 의미하는 것은?
☆ semaphore 사용할 때 atomic fashion을 사용하라는 의미인가?
Subsystems
· Bluetooth
- Bluetooth 5.0 compliant
- Bluetooth low energy controller support(LE Link Layer)
- Generic Access Profile(GAP) with all possible LE roles
- Generic Attribute Profile(GATT) : Server(sensor), Client(connect to sensors)
- Pairing support
- IPSP/6LowPAN for IPv6 connectivity over Bluetooth LE
- Basic Bluetooth support
- Clean HCI driver abstraction
- Raw HCI interface to run Zephyr as a Controller instead of a full Host stack
- Verified with multiple popular controllers
- Highly configurable
-Features, buffer sizes/counts, stack sizes, etc
- Bluetooth API
☆ Bluetooth API 확인해보기
· Power Management ☆☆☆
- implement power management support that can take full advantage of the power saving features of SOCs
- Terminology
- SOC interface : knowledge of the SOC, hardware features
- CPU LPS(Low Power State) : low power state supported by CPU
- Active State : CPU and clocks are powered on
- Deep Sleep State : CPU is power gated and loses context, 다시 복구하는데 시간 소요
- SOC Power State : described processor and device power state
- Idle Thread : system thread that runs when there are no other threads ready to run
- Power gating : power gating reduces power consumption by shutting off current to blocks of the integrated circuit that are not in use
☆ deep sleep state에서 다시 깨어나는 조건을 줘야 깨어나는 것인가?(아마도 time interrupt?)
☆ 한번에, 다른 과정 없이 deep sleep state로 들어갈 수 있는지?(예제)
☆ power gating 해서 power management 해야함
☆ DPM(Dynamic Power Management)
- power management features
· Tickless Idle
- identify the event-based idling mechanism of the Zephyr kernel scheduler
- periodic mode(interval-based mode)
- when at least one thread is active, it sets up the system timer in periodic mode
- when at least one thread is active, it sets up the system timer to time slice between tasks
- when there are no threads running, it is inefficient for the kernel scheduler to run in interval-based mode
☆ thread 들어가는 API 정리
☆ Power management API를 이용한 예제 찾아보기
☆ 주기적 동작하면 주기적으로 깨어나서 실행, 깨어나면 시간 조정
· System Power Management
- hook function that the power management subsystem calls when the kernel enters and exits the idle state
- Suspend Hook function : _sys_soc_suspend()
- Resume Hook function : _sys_soc_resume()
- Resume From Deep Sleep Hook function : _sys_soc_resume_from_deep_sleep()
- Power Schemes
- SYS_PM_LOW_POWER_STATE
: CPU does not lose execution context
Devices also do not lose power
- SYS_PM_DEEP_SLEEP
: CPU is power gated and loses execution context
Execution will resume at OS startup code or at a resume point determined by a bootloader
☆ lower power mode에서와 deep sleep mode에서의 전력 측정
☆ mode에 들어가는 건 순서대로 진행하는 것인가?
· Device Power Management
- Zephyr supports 2 methods of doing device power management
· Distributed method
- saves power if some devices that are not in use can be turned off or put in power saving mode
- saving power even then CPU is active
·Central method
- device power management is mostly done inside _sys_soc_suspend() along with entering a CPU or SOC low power state
- If a decision to enter sleep is made, the implementation would enter it only after checking if the devices are not in the middle of a hardware transaction that cannot be interrupted
☆ CPU는 켜져있고, 사용하지 않는 camera(module)은 끌 수 있나?(코드 확인)
- Device Power Management state
- DEVICE_PM_ACTIVE_STATE
: Normal operation of the device
All device context is retained
- DEVICE_PM_LOW_POWER_STATE
: Device context is preserved by the HW and need not be restored by the driver
- DEVICE_PM_SUSPEND_STATE
: Most device context is lost by the HW
Device drivers must save and restore of reinitialize any context lost by the HW
- DEVICE_PM_OFF_STATE
: Power has been fully removed from the device
The device context is lost when this state is entered
Need to reinitialize the device when powering it back on
- Device Power Management API
- Get device list : device_list_get
- Device set power state : device_set_power_state
- Device get power state : device_get_power_state
☆ timeslice로 동작하면 edf 어려운가?
☆ scheduling point 확인(timer event 발생때마다 구현되는가?-새로운 thread 발생?-schedule?)
'나름컴공이라공 > Study' 카테고리의 다른 글
JAVA study_#1 eclipse 설치(MAC) (0) | 2020.04.26 |
---|---|
20150922 핵심취업전략_3 (0) | 2019.07.19 |
20150915 취업전략_2 (0) | 2019.07.19 |
20150908 취업전략_1 (0) | 2019.07.19 |
정보처리기사 응시자격 서류제출!! (0) | 2019.07.19 |