본문 바로가기
Development Solutions/Embedded System

RTOS 2 - uC/OS real-time kernel architecture (RTOS 2 - uC/OS 실시간 커널 구조)

by Dev Diary Hub 2022. 8. 20.
반응형

RTOS 2 - uC/OS real-time kernel architecture

RTOS 2 - uC/OS 실시간 커널 구조

 

2022.08.20 - [Development Solutions/Embedded System] - RTOS 1 - Overview (RTOS 1 - 개요)

 

RTOS 1 - Overview (RTOS 1 - 개요)

RTOS 1 - Overview RTOS 1 - 개요 - RTOS : 주어진 입력 조건을 정해진 시간 내에 처리하는 시스템 : Hard RTOS -> micro Controller / OS-II 를 주로 다룰 것임 : Soft RTOS -> 이번 글에선 다루지 않음 :..

studiodoc.tistory.com

 

(추천) Qt QML과 C++로 시작하는 크로스플랫폼 앱 개발 강의 - 입문편

https://inf.run/3XmSH

 

Qt QML과 C++로 시작하는 크로스플랫폼 앱 개발 - 입문편 강의 - 인프런

Qt QML과 C++를 사용하여 크로스플랫폼 애플리케이션 개발에 입문할 수 있습니다. 해당 강의에서는 윈도우 응용 프로그램 타겟으로 개발을 진행합니다., 강의 주제 📖 이 강의를 통해 참가자들은

www.inflearn.com

 

- uC/OS 특징

: 커널 코드의 대부분이 C 기반이라 이식하기 쉬움

: 선점형 스케줄링

: Real Time OS

: 우선순위를 이용한 멀티태스킹 지원

: 신뢰성과 안정성

: 인터럽트 관리(중첩, 일시정지: OSTaskSuspend(), 재개: OSTaskResume())

: 스택 체크, Mail Box, Mail Queue, Semaphore 등의 시스템 서비스 제공

: 같은 우선순위를 제공하지 않으므로, 라운드 로빈 기법 적용 불가

 

- uC/OS 태스크
: 태스크의 ID가 곧 태스크의 우선순위. 이 값이 낮을수록 우선순위는 높아짐
: Ready 상태의 태스크 중 가장 높은 우선순위의 태스크 실행
: ISR: 인터럽트 발생 후, CPU가 수행하는 인터럽트 서비스 루틴
: TCB
: 태스크 생성시 각 태스크에게 할당되는 Task Control Block
: OS_TCB는 메모리에 상주하여 태스크 상태 관리
: TCB가 담고있는 내부 변수
: OSTCBStkPtr: 태스크 스택을 가리키는 포인터(스택 포인터 인자를 최상위 인자로 배치하는 이유는 어셈블리 언어의 효율성 증대를 위함)
: OSTCBStat: 태스크의 상태 표시 비트 (ucos.c)
: OSTCBPrio: 태스크의 우선순위
: OSTCBDly: 태스크의 지연 시간. 이벤트 발생 대기용
: OSTCBX, OSTCBY, OSTCBBitX, OSTCBBitY: 태스크가 생성되거나 우선순위가 바뀔 때 사용
OSTCBY = prio >> 3;
OSTCBX = prio & 0x07;
OSTCBBitY = 1 << OSTCBY;
OSTCBBitX = 1 << OSTCBX;
: OSTCBNext, OSTCBPrev: TCB를 양방향으로 링크
: OSTCBEventPtr: Event Control Block를 가리키는 포인터
: OSTaskCreate(): 태스크 생성
: OSTaskDel(): 태스크 삭제
: OSTaskDelReq(): 공유자원을 점유한 태스크 삭제(삭제를 요청하는 쪽과 삭제 대상이 되는 쪽 모두에서 호출)
: OSTaskQuery(): 태스크 정보 획득
: OS_TCBInIt(): TCB구조체를 새로 만들고, 세팅하여 TCBList에 추가
: Task Ready List: OSRdyGrp과 OSRdyTbl[]를 통해 Ready 상태 태스크 관리
: 더욱 빠르게 찾기 위하여, 미리 계산한 결과를 담은 Lookup Table을 이용해서 OSTCBX ,OSTCBY 값을 찾고, 우선순위를 계산하여 Ready List 중 최고 우선순위의 태스크 찾거나 List에 추가하거나 제거함
: OS_Sched(): 우선순위가 가장 높은 태스크를 실행함
: Context Switch(os_cpu_a.asm에 구현): R4~R11는 LDM 명령어를 통해 수동 백업or복원하고, R0~R3,R12,LR,PC,xPSR은 자동 백업or복원(PSP, 프로세스 스택 포인터 이용)
: OSSchedLock(): 스케줄링 잠금 설정. OSLockNesting 변수 이용
: OSSchedUnlock(): 스케줄링 잠금 해제. (OSLockNesting--후, OSLockNesting==0이어야 해제됨)
: Idle Task: Ready 상태의 태스크가 없을 경우, 시스템에 의해 자동 실행되는 태스크
: Statistics Task: CPU 사용률 계산. 전체 CPU 수행 카운트 중에 Idle Task가 수행된 카운트를 제외한 카운트의 비율

 

반응형

(

- uC/OS Features

: Most of the kernel code is C-based, so portability is easy.

: Preemptive Scheduling

: Real Time OS

: Multitasking support using priority

: Reliability and Stability

: Interrupt management (nested, pause: OSTaskSuspend(), resume: OSTaskResume())

: Provides system services such as stack check, Mail Box, Mail Queue, Semaphore, etc.

: Since the same priority is not provided, round robin technique cannot be applied.



- uC/OS task
: The task ID is the priority of the task. The lower this value, the higher the priority.
: Execute the task with the highest priority among the tasks in the Ready state
: ISR: Interrupt service routine executed by CPU after interrupt occurs
: TCB
: Task Control Block assigned to each task when creating a task
: OS_TCB resides in memory to manage task state
: Internal variable contained in TCB
: OSTCBStkPtr: A pointer to the task stack (the reason for placing the stack pointer argument as the topmost argument is to increase assembly language efficiency)
: OSTCBStat: Status display bit of task (ucos.c)
: OSTCBPrio: Priority of task
: OSTCBDly: The delay time of the task. To wait for an event to occur
: OSTCBX, OSTCBY, OSTCBBitX, OSTCBBitY: Used when a task is created or the priority is changed
OSTCBY = prio >> 3;
OSTCBX = prio & 0x07;
OSTCBBitY = 1 << OSTCBY;
OSTCBBitX = 1 << OSTCBX;
: OSTCBNext, OSTCBPrev: Link TCB in both directions
: OSTCBEventPtr: Pointer to the Event Control Block
: OSTaskCreate(): Create a task
: OSTaskDel(): delete task
: OSTaskDelReq(): Delete a task that occupies a shared resource (called by both the party requesting the deletion and the party to be deleted)
: OSTaskQuery(): Get task information
: OS_TCBInIt(): Creates a new TCB structure, sets it, and adds it to the TCBList
: Task Ready List: Manage Ready status tasks through OSRdyGrp and OSRdyTbl[]
: To find faster, find the OSTCBX and OSTCBY values ​​using the Lookup Table containing the pre-calculated results, calculate the priority, and find the task with the highest priority among the Ready List, add it to the list, or remove it
: OS_Sched(): Executes the task with the highest priority
: Context Switch (implemented in os_cpu_a.asm): R4~R11 manual backup or restore through LDM command, R0~R3,R12,LR, PC,xPSR automatically backup or restore (PSP, process stack pointer)
: OSSchedLock(): Set a scheduling lock. Using the OSLockNesting variable
: OSSchedUnlock(): Unlock scheduling. (After OSLockNesting--, OSLockNesting==0 to unlock)
: Idle Task: A task automatically executed by the system when there is no task in the Ready state.
: Statistics Task: Calculating CPU utilization. The ratio of the total CPU execution count, excluding the count where the idle task is performed.

)

 

 
첨부 링크 (Attachment link)

본 게시글은 개인 공부용으로 작성하여 내용의 퀄리티가 부족할 수 있습니다. 

 

(추천) Qt QML과 C++로 시작하는 크로스플랫폼 앱 개발 강의 - 입문편

https://inf.run/3XmSH

 

Qt QML과 C++로 시작하는 크로스플랫폼 앱 개발 - 입문편 강의 - 인프런

Qt QML과 C++를 사용하여 크로스플랫폼 애플리케이션 개발에 입문할 수 있습니다. 해당 강의에서는 윈도우 응용 프로그램 타겟으로 개발을 진행합니다., 강의 주제 📖 이 강의를 통해 참가자들은

www.inflearn.com

 

반응형