ubinos
Classes | Macros | Typedefs | Functions
ubik.h File Reference

ubik (Ubinos Kernel) API More...

#include <ubinos_config.h>
#include <ubinos/type.h>
#include <ubinos/ubik/task.h>
#include <ubinos/ubik/signal.h>
#include <ubinos/ubik/sem.h>
#include <ubinos/ubik/mutex.h>
#include <ubinos/ubik/msgq.h>
#include <ubinos/ubik/condv.h>
#include <ubinos/ubik/hrtick.h>
#include <ubinos/ubik/stimer.h>

Go to the source code of this file.

Classes

struct  _tickcount_t
 

Macros

#define UBIK_ERR__SUCCESS   0
 
#define UBIK_ERR__FAIL   -1
 
#define UBIK_ERR__TIMEOUT   -20
 
#define UBIK_ERR__DEADLOCK   -21
 
#define UBIK_ERR__TERMINATED   -30
 
#define UBIK_ERR__OVERFLOWED   -50
 
#define UBIK_TAG__USRSTART   0x8000
 
#define IDLEHOOKFUNC_OPT__REPEAT   0x00
 
#define IDLEHOOKFUNC_OPT__ONCE   0x80
 

Typedefs

typedef int(* idletaskhookfunc_ft) (void *)
 
typedef void(* tickhookfunc_ft) (void)
 
typedef struct _tickcount_t tickcount_t
 

Functions

int ubik_comp_init (unsigned int idle_stackdepth)
 
int ubik_comp_start (void)
 
unsigned int ubik_gettickpersec (void)
 
tickcount_t ubik_gettickcount (void)
 
tickcount_t ubik_gettickdiff (tickcount_t tick1, tickcount_t tick2)
 
unsigned int ubik_timemstotick (unsigned int timems)
 
unsigned int ubik_ticktotimems (unsigned int tick)
 
int ubik_settickhookfunc (tickhookfunc_ft tickhookfunc)
 
int ubik_isactive (void)
 
void ubik_entercrit (void)
 
void ubik_exitcrit (void)
 
int ubik_iscrit (void)
 
int ubik_istask (void)
 
int ubik_collectgarbage (void)
 
int ubik_sprintkernelinfo (char *buf, int max)
 
int ubik_printkernelinfo (void)
 
int ubik_setidletaskhookfunc (idletaskhookfunc_ft func, void *arg, const char *name, unsigned int option)
 
int ubik_setrtpriority (int rtpriority)
 
int ubik_getrtpriority (void)
 
int ubik_isrt (void)
 

Detailed Description

ubik (Ubinos Kernel) API

ubik (Ubinos Kernel) API를 정의합니다.

Macro Definition Documentation

◆ IDLEHOOKFUNC_OPT__ONCE

#define IDLEHOOKFUNC_OPT__ONCE   0x80

아이들 태스크 후크 함수 선택 사항: 설정된 후크 함수를 한번만 수행함

◆ IDLEHOOKFUNC_OPT__REPEAT

#define IDLEHOOKFUNC_OPT__REPEAT   0x00

아이들 태스크 후크 함수 선택 사항: 설정된 후크 함수를 반복해서 수행함(기본 설정)

◆ UBIK_ERR__DEADLOCK

#define UBIK_ERR__DEADLOCK   -21

오류: 교착 상태에 빠질 가능성이 있음

◆ UBIK_ERR__FAIL

#define UBIK_ERR__FAIL   -1

오류: 실패

◆ UBIK_ERR__OVERFLOWED

#define UBIK_ERR__OVERFLOWED   -50

오류: 오버플로우 발생

◆ UBIK_ERR__SUCCESS

#define UBIK_ERR__SUCCESS   0

오류: 오류 없음

◆ UBIK_ERR__TERMINATED

#define UBIK_ERR__TERMINATED   -30

오류: 대상 객체가 제거되었음

◆ UBIK_ERR__TIMEOUT

#define UBIK_ERR__TIMEOUT   -20

◆ UBIK_TAG__USRSTART

#define UBIK_TAG__USRSTART   0x8000

사용자 태그 시작값

Typedef Documentation

◆ idletaskhookfunc_ft

typedef int(* idletaskhookfunc_ft) (void *)

아이들 태스크 후크 함수 포인터 형 정의

◆ tickcount_t

typedef struct _tickcount_t tickcount_t

tick 수 형 정의

◆ tickhookfunc_ft

typedef void(* tickhookfunc_ft) (void)

틱 후크 함수 포인터 형 정의

Function Documentation

◆ ubik_collectgarbage()

int ubik_collectgarbage ( void  )

사용 중이 아닌 자원들을 정리하는 함수

Returns
0: 성공

-1: 오류
Examples
condvtest04.c, msgqtest04.c, mutextest04.c, semtest04.c, signaltest04.c, stimertest03.c, and tasktest06.c.

◆ ubik_comp_init()

int ubik_comp_init ( unsigned int  idle_stackdepth)

ubik 컴포넌트를 초기화하는 함수

이 함수는 시스템 시작시 bsp 컴포넌트의 main 함수에서 자동적으로 호출됩니다.

Parameters
idle_stackdepthidle task 스택 깊이(스택 영역 크기는 stackdepth * INT_SIZE 바이트가 됨)
0: 기본 스택 깊이 값(task_getdefaultstackdepth 함수가 돌려주는 값)
1 ~ 최저 스택 깊이 값: 최저 스택 깊이 값(task_getminstackdepth 함수가 돌려주는 값)

Returns
0: 성공

-1: 오류

◆ ubik_comp_start()

int ubik_comp_start ( void  )

ubik 컴포넌트를 시작하는 함수

Returns
0: 성공

-1: 오류

◆ ubik_entercrit()

void ubik_entercrit ( void  )

크리티컬 섹션으로 들어가는 함수

◆ ubik_exitcrit()

void ubik_exitcrit ( void  )

크리티컬 섹션에서 빠져나오는 함수

◆ ubik_getrtpriority()

int ubik_getrtpriority ( void  )

실시간 태스크 우선순위를 가져오는 함수

Returns
실시간 태스크 우선순위

-1: 오류
-n: n-1 번째 매개변수가 잘못되었음

◆ ubik_gettickcount()

tickcount_t ubik_gettickcount ( void  )

현재까지 누적된 tick 수를 돌려주는 함수

Returns
현재까지 누적된 tick 수
Examples
misctest02.c.

◆ ubik_gettickdiff()

tickcount_t ubik_gettickdiff ( tickcount_t  tick1,
tickcount_t  tick2 
)

tick 수의 차이(tick2에서 tick1을 뺀 값)를 돌려주는 함수

비교 대상 tick 1이 비교 대상 tick 2보다 클 경우 오버플로우가 일어난 것으로 간주하고 차이를 계산함

Parameters
tick1비교 대상 tick 1

tick2비교 대상 tick 2

Returns
tick 수의 차이
Examples
misctest02.c.

◆ ubik_gettickpersec()

unsigned int ubik_gettickpersec ( void  )

초당 tick 수를 돌려주는 함수

Returns
초당 tick 수
Examples
misctest02.c.

◆ ubik_isactive()

int ubik_isactive ( void  )

ubik 컴포넌트가 active 상태인지 여부를 돌려주는 함수

Returns
1: active
0: inactive

◆ ubik_iscrit()

int ubik_iscrit ( void  )

크리티컬 섹션 또는 인터럽트 서비스 루틴을 수행 중인지 여부를 알려주는 함수

Returns
1: 크리티컬 섹션 또는 인터럽트 서비스 루틴을 수행 중임
0: 크리티컬 섹션 또는 인터럽트 서비스 루틴을 수행 중이 아님

◆ ubik_isrt()

int ubik_isrt ( void  )

실시간 태스크, 태스크 잠금 상태의 태스크, 크리티컬 섹션, 또는 인터럽트 서비스 루틴을 수행 중인지 여부를 알려주는 함수

Returns
1: 실시간 태스크, 태스크 잠금 상태의 태스크, 크리티컬 섹션, 또는 인터럽트 서비스 루틴을 수행 중임
0: 실시간 태스크, 태스크 잠금 상태의 태스크, 크리티컬 섹션, 또는 인터럽트 서비스 루틴을 수행 중이 아님

-1: 오류
-n: n-1 번째 매개변수가 잘못되었음

◆ ubik_istask()

int ubik_istask ( void  )

태스크를 수행 중인지 여부를 알려주는 함수

Returns
1: 태스크를 수행 중임
0: 시스템 초기화 루틴 또는 인터럽트 서비스 루틴을 수행 중임

◆ ubik_printkernelinfo()

int ubik_printkernelinfo ( void  )

커널 정보를 출력하는 함수

Returns
0: 성공

-1: 오류
Examples
misctest01.c.

◆ ubik_setidletaskhookfunc()

int ubik_setidletaskhookfunc ( idletaskhookfunc_ft  func,
void *  arg,
const char *  name,
unsigned int  option 
)

아이들 태스크 후크 함수를 설정하는 함수

설정된 후크 함수는 아이들 태스크 내에서 호출됨

아이들 태스크는 일반 태스크와는 달리 task_sleep 함수를 호출할 경우 바쁜 기다림busy waiting을 수행한다. 그리고 sem_take, sem_take_timed 함수와 같은 특정 조건이 만족되기를 기다리는 함수를 호출할 경우 스핀 기다림spin waiting을 수행하기 때문에 최대 UBINOS__UBIK__IDLETASK_SPINWAIT_INTERVALTICK 으로 정의된 시스템 틱 수 만큼 응답 시간이 지연될 수 있다.

Parameters
func설정할 후크 함수 포인터
NULL: 후크 함수 설정 해제

arg후크 함수로 전달할 매개변수

name후크 함수 이름
NULL: 후크 함수 이름을 지정하지 않음

option선택 사항 (IDLEHOOKFUNC_OPT__...)
0: 기본 설정 사용

Returns
0: 성공

-1: 오류
-n: n-1 번째 매개변수가 잘못되었음

◆ ubik_setrtpriority()

int ubik_setrtpriority ( int  rtpriority)

실시간 태스크 우선순위를 설정하는 함수

이 함수로 설정된 실시간 태스크 우선순위 이상의 우선 순위를 가진 태스크를 실시간 태스크로 간주한다.
실기간 태스트 우선순위가 설정되어 있지 않으면 모든 태스크를 비실시간 태스크로 간주한다.

Parameters
rtpriority실시간 태스크 우선순위
Returns
0: 성공

-1: 오류
-n: n-1 번째 매개변수가 잘못되었음

◆ ubik_settickhookfunc()

int ubik_settickhookfunc ( tickhookfunc_ft  tickhookfunc)

틱 후크 함수를 등록하는 함수

틱 후크 함수는 시스템 틱 인터럽트가 발생할 때마다 자동적으로 호출된다.

Parameters
tickhookfunc틱 후크 함수 포인터
NULL: 틱 후크 함수 등록 해제
Returns
0: 성공

-1: 오류

◆ ubik_sprintkernelinfo()

int ubik_sprintkernelinfo ( char *  buf,
int  max 
)

커널 정보를 문자열 형태로 메모리 버퍼에 기록하는 함수

Parameters
buf기록할 메모리 버퍼

max메모리 버퍼의 크기

Returns
기록된 문자열 크기

-1: 오류
-n: n-1 번째 매개변수가 잘못되었음

◆ ubik_ticktotimems()

unsigned int ubik_ticktotimems ( unsigned int  tick)

시스템 tick 수를 시간(천분의 일초)으로 환산하는 함수

Parameters
tick시스템 tick 수

Returns
시간(천분의 일초)
시간(천분의 일초)으로 환산했을 때 0이지만 tick이 0이 아니면 1
Examples
msgqtest01.c, mutextest01.c, semtest01.c, stimertest01.c, stimertest02.c, tasktest02.c, tasktest07.c, tasktest08.c, and tasktest09.c.

◆ ubik_timemstotick()

unsigned int ubik_timemstotick ( unsigned int  timems)

시간(천분의 일초)을 시스템 tick 수로 환산하는 함수

Parameters
timems시간(천분의 일초)

Returns
시스템 tick 수
시스템 tick 수로 환산했을 때 0이지만 timems가 0이 아니면 1
Examples
condvtest01.c, condvtest02.c, condvtest03.c, msgqtest01.c, msgqtest02.c, msgqtest03.c, mutextest01.c, mutextest02.c, mutextest03.c, semtest01.c, semtest02.c, semtest03.c, signaltest01.c, signaltest02.c, signaltest03.c, stimertest00.c, stimertest01.c, stimertest02.c, tasktest00.c, tasktest02.c, tasktest03.c, tasktest04.c, tasktest05.c, tasktest06.c, tasktest07.c, tasktest08.c, and tasktest09.c.