KR20080054324A - Method for allocation stack in multi-threaded sensor operating systems environment - Google Patents

Method for allocation stack in multi-threaded sensor operating systems environment Download PDF

Info

Publication number
KR20080054324A
KR20080054324A KR1020070029595A KR20070029595A KR20080054324A KR 20080054324 A KR20080054324 A KR 20080054324A KR 1020070029595 A KR1020070029595 A KR 1020070029595A KR 20070029595 A KR20070029595 A KR 20070029595A KR 20080054324 A KR20080054324 A KR 20080054324A
Authority
KR
South Korea
Prior art keywords
stack
function
allocated
size
allocation method
Prior art date
Application number
KR1020070029595A
Other languages
Korean (ko)
Other versions
KR100846451B1 (en
Inventor
김상철
신창민
장진호
김해용
조유근
홍지만
허준영
이상호
구본철
민홍
이승우
Original Assignee
한국전자통신연구원
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 한국전자통신연구원 filed Critical 한국전자통신연구원
Priority to US11/753,023 priority Critical patent/US20080140979A1/en
Publication of KR20080054324A publication Critical patent/KR20080054324A/en
Application granted granted Critical
Publication of KR100846451B1 publication Critical patent/KR100846451B1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

A method for allocation stack in a multi-threaded sensor OS(Operating System) environment is provided to allocate a thread stack with space efficiency in a sensor OS operated in a space restricted sensor platform and reduce usage of a memory space remarkably more than a usual static thread stack allocation method. A stack space used by a called function is allocated by estimating the size of the allocated stack space based on the size of local variables and the number of function factors used by the function when the function is called during execution of the thread(220). A stack pointer is moved to point the allocated stack space(230). A factor and a return address of the function are stored in the stack space(240). The function is returned when the function is terminated(270). The stack pointer is restored and the allocated stack space is returned(280).

Description

멀티 쓰레드 기반 센서 운영체제 환경에서의 스택 할당 방법{METHOD FOR ALLOCATION STACK IN MULTI-THREADED SENSOR OPERATING SYSTEMS ENVIRONMENT}Stack Allocation Method in Multi-Thread-Based Sensor Operating System Environment {METHOD FOR ALLOCATION STACK IN MULTI-THREADED SENSOR OPERATING SYSTEMS ENVIRONMENT}

도 1은 본 발명의 일 실시예에 따른 멀티 쓰레드 기반 센서 운영체제 환경에서의 스택 할당 방법을 개략적으로 설명하기 위한 흐름도.1 is a flowchart illustrating a stack allocation method in a multi-threaded sensor operating system environment according to an embodiment of the present invention.

도 2는 도 1의 스택 할당 방법을 좀더 구체적으로 설명하는 흐름도.2 is a flow chart illustrating the stack allocation method of FIG. 1 in more detail.

도 3은 본 발명의 일 실시예에 따른 멀티 쓰레드 기반 센서 운영체제 환경에서의 스택 할당 방법과 종래 기술의 정적인 스택 할당 방법을 비교하기 위한 스택 영역의 할당 예를 나타낸 도면.3 is a diagram illustrating an example of allocation of a stack area for comparing a stack allocation method in a multi-threaded sensor operating system environment according to an embodiment of the present invention and a static stack allocation method according to the related art.

도 4는 본 발명의 일 실시예에 따른 멀티 쓰레드 기반 센서 운영체제 환경에서의 스택 할당 방법과 종래 기술의 정적인 스택 할당 방법을 비교하기 위한 스택 할당량을 나타낸 그래프.4 is a graph illustrating a stack allocation for comparing a stack allocation method in a multi-threaded sensor operating system environment according to an embodiment of the present invention and a static stack allocation method according to the related art.

본 발명은 멀티 쓰레드 기반 센서 운영체제 환경에서의 스택 할당 방법에 관 한 것으로, 보다 상세하게는 쓰레드(Thread)가 필요로 하는 만큼의 스택 영역(Stack Space)의 할당을 동적으로 수행함으로써, 스택 영역을 보다 효율적으로 활용할 수 있도록 한 멀티 쓰레드 기반 센서 운영체제 환경에서의 스택 할당 방법에 관한 것이다.The present invention relates to a stack allocation method in a multi-threaded sensor operating system environment. More particularly, the present invention relates to stack allocation by dynamically allocating as much stack space as a thread requires. The stack allocation method in a multi-threaded sensor operating system environment can be utilized more efficiently.

일반적으로, 무선 센서 네트워크(Wireless Sensor Networks)는 여러 가지 환경 정보를 센싱(Sensing)하고 사용자가 원하는 형태로 정보를 가공하여 실시간으로 통신하는 무선 네트워크이다. 이러한 무선 센서 네트워크는 수백 혹은 수천 개의 무선 센서 노드들로 이루어진다. 각 센서 노드(Sensor Node)는 비용적인 측면에서 매우 작은 크기로 구성되어야 전체 네트워크의 비용 효율성을 이루어낼 수 있게 된다. 상기 센서 노드들은 환경 정보를 수집하고, 이웃 노드들끼리 통신하며, 정보를 가공하여 사용자에게 실시간으로 전달하는 기능을 담당한다.In general, wireless sensor networks are wireless networks that sense various environmental information and process the information in the form desired by the user to communicate in real time. Such a wireless sensor network consists of hundreds or thousands of wireless sensor nodes. Each Sensor Node must be configured in a very small size in terms of cost, so that the entire network can be cost-effective. The sensor nodes are responsible for collecting environmental information, communicating with neighboring nodes, processing the information, and delivering the information to the user in real time.

즉, 상기 센서 노드는 온도, 습도 및 광량 정보 등을 얻어낼 센서와 간단한 계산을 수행할 수 있는 중앙처리유닛(CPU), 무선 통신을 위한 RF 모듈, 부팅을 위한 작은 크기의 롬(ROM) 과 메인 배터리 등으로 구성된다. 예를 들면, 미국의 버클리 대학에서 설계한 MICA 시리즈 센서 플랫폼은 8비트(bit) 중앙처리유닛(CPU), 4KB 램(RAM) 및 두개의 AA 배터리 등으로 구성되어 있다.That is, the sensor node includes a sensor for obtaining temperature, humidity and light quantity information, a central processing unit (CPU) for performing simple calculations, an RF module for wireless communication, a small ROM for booting, and It consists of a main battery. For example, the MICA series sensor platform, designed by the University of Berkeley, consists of an 8-bit central processing unit (CPU), 4KB of RAM, and two AA batteries.

이러한 센서 플랫폼에서 동작할 센서 운영체제는 제한적인 메모리 공간을 효율적으로 사용하면서 센서 노드에서 발생할 수 있는 센싱, 통신 및 변환 등의 다수의 작업을 실시간으로 처리하기 위한 멀티 쓰레드 기반 태스크 관리(Multi-Threaded Task Management) 기법이 필요하다.The sensor operating system, which will operate on such a sensor platform, uses multi-threaded task management to efficiently process a large number of tasks such as sensing, communication, and transformation that can occur in a sensor node while using a limited memory space efficiently. Management technique is required.

이를 해결하기 위하여, 기존의 정적인 쓰레드 스택 할당 방법은 쓰레드 생성 시에 해당 쓰레드가 사용할 스택 영역을 정적인 크기로 할당하였다. 즉, 각 쓰레드마다 고유의 스택을 메모리 공간에 할당받아야 한다.To solve this problem, the existing static thread stack allocation method allocates a statically sized stack area for the thread when the thread is created. In other words, each thread must have its own stack allocated in memory space.

이러한 스택 영역의 할당은 매우 제한적인 메모리 공간을 갖는 센서 플랫폼에서는 상당한 문제가 된다. 쓰레드가 할당받은 스택 영역을 전부 사용하지 않는다면, 남는 공간은 스택 영역의 낭비로 이어진다. 그러므로, 공간 제약적인 무선 센서 플랫폼에서의 스택 메모리 공간의 정적인 할당 및 반납은 자원 관리의 측면에서 심각한 문제점을 일으킬 수 있다.This allocation of stack area is a significant problem for sensor platforms with very limited memory space. If the thread does not use all the allocated stack space, the remaining space is a waste of stack space. Therefore, static allocation and return of stack memory space in space-constrained wireless sensor platforms can cause serious problems in terms of resource management.

이러한 문제점은 실제로 시스템의 메모리 부족 문제 등을 일으키는 주원인이 되고, 전체 무선 센서 네트워크의 오작동을 일으키게 된다. 이러한 멀티 쓰레드 기반 태스크 관리 기법의 사용에 있어서의 문제를 확실히 해결하기 위한 방안은 존재하지 않았다.This problem actually causes the memory shortage of the system, etc., and causes a malfunction of the entire wireless sensor network. There was no way to reliably solve the problem of using this multithreaded task management technique.

한편, 통상의 멀티 쓰레드 기반 기법이 아닌 이벤트 기반 프로그래밍 기법을 사용하여 메모리 공간의 문제를 해결하려는 시도가 있으나, 이러한 이벤트 기반 구조는 실시간 작업 처리를 위한 선점 기능을 제공하지 않는 문제점이 있다.On the other hand, there is an attempt to solve the problem of memory space by using an event-based programming technique rather than a conventional multi-threaded technique, but such an event-based structure does not provide a preemption function for real-time task processing.

본 발명은 전술한 문제점을 해결하기 위하여 안출된 것으로서, 본 발명의 목적은 공간 제약적인 센서 플랫폼에서 동작하는 센서 운영체제를 위한 공간 효율적인 쓰레드 스택 할당 방법을 제공하는데 있다.SUMMARY OF THE INVENTION The present invention has been made to solve the above-described problem, and an object of the present invention is to provide a space-efficient thread stack allocation method for a sensor operating system operating in a space-constrained sensor platform.

본 발명의 다른 목적은 기존의 정적인 쓰레드 스택 할당 방법을 사용하는 것보다 메모리 공간의 사용량을 상당히 절감시킬 수 있는 멀티 쓰레드 기반 센서 운영체제 환경에서의 스택 할당 방법을 제공하는데 있다.Another object of the present invention is to provide a stack allocation method in a multi-threaded sensor operating system environment that can significantly reduce the memory space usage than using a conventional static thread stack allocation method.

본 발명의 또 다른 목적은 전체 메모리 공간을 효율적으로 사용하면서 다중 작업을 실시간으로 수행시킬 수 있는 공간 효율적인 쓰레드 스택 할당 방법을 제공하는데 있다.It is still another object of the present invention to provide a space efficient thread stack allocation method capable of performing multiple tasks in real time while efficiently using the entire memory space.

전술한 목적을 달성하기 위하여, 본 발명의 제1 측면에 따른 멀티 쓰레드 기반 센서 운영체제 환경에서의 동적 스택 할당 방법은, 쓰레드의 작업 수행 중에 함수의 호출 시마다 상기 호출된 함수에 의해 사용될 스택 영역을 동적으로 할당하는 단계와, 상기 함수의 실행이 종료되면 상기 할당된 스택 영역을 반납하는 단계를 포함한다.In order to achieve the above object, the dynamic stack allocation method in a multi-threaded sensor operating system environment according to the first aspect of the present invention, dynamic stack allocation to be used by the called function every time the function is called during the execution of the task of the thread. And returning the allocated stack area when execution of the function is terminated.

바람직하게, 상기 방법은 상기 함수에 의해 사용될 지역 변수의 크기 및 함수 인자의 개수에 기반하여 상기 할당될 스택 영역의 크기를 예측하는 단계를 더 포함한다.Advantageously, the method further comprises estimating the size of said stack area to be allocated based on the size of a local variable to be used by said function and the number of function arguments.

다른 실시예에서, 상기 방법은 상기 함수에 대응하는 어셈블리 코드를 분석함으로써 상기 할당될 스택 영역의 크기를 예측하는 단계를 더 포함한다.In another embodiment, the method further comprises estimating the size of the stack area to be allocated by analyzing assembly code corresponding to the function.

본 발명의 제2 측면에 따른 멀티 쓰레드 기반 센서 운영체제 환경에서의 동적 스택 할당 방법은, 쓰레드의 작업 수행 중에 함수가 호출되는 경우에 상기 호출 된 함수에 의해 사용될 스택 영역을 할당하는 단계와, 상기 할당된 스택 영역을 가리키도록 스택 포인터를 이동시키는 단계와, 상기 함수의 인자 및 리턴 주소를 상기 스택 영역에 저장하는 단계와, 상기 함수의 실행이 종료되면 상기 함수를 리턴하는 단계와, 상기 스택 포인터를 복원하고 상기 할당된 스택 영역을 반납하는 단계를 포함한다.A dynamic stack allocation method in a multi-threaded sensor operating system environment according to the second aspect of the present invention includes the steps of: allocating a stack area to be used by the called function when a function is called during the execution of a thread; Moving a stack pointer to point to a stacked stack region, storing arguments and return addresses of the function in the stack region, returning the function when execution of the function is finished, and stack stack Restoring and returning the allocated stack region.

이하, 첨부 도면을 참조하여 본 발명의 실시예를 상세하게 설명한다. 그러나, 다음에 예시하는 본 발명의 실시예는 여러 가지 다른 형태로 변형될 수 있으며, 본 발명의 범위가 다음에 상술하는 실시예에 한정되는 것은 아니다. 본 발명의 실시예는 당업계에서 통상의 지식을 가진 자에게 본 발명을 보다 완전하게 설명하기 위하여 제공되어지는 것이다.Hereinafter, embodiments of the present invention will be described in detail with reference to the accompanying drawings. However, embodiments of the present invention illustrated below may be modified in many different forms, and the scope of the present invention is not limited to the embodiments described below. The embodiments of the present invention are provided to more completely explain the present invention to those skilled in the art.

우선, 본 발명에서 사용되는 용어를 간략히 설명한다.First, the terms used in the present invention will be briefly described.

" 쓰레드"는 하나의 프로그램 내에서의 실행 단위를 의미한다. 예컨대, 자바(Java)에서는 각 작업(Task)을 쓰레드로 표현하고, 이러한 쓰레드를 여러 개 둘 수 있도록 함으로써 멀티태스킹(Multi-Tasking)을 가능하게 한다. "Thread" means a unit of execution within a program. For example, in Java, each task is represented as a thread, and multi-tasking is possible by allowing several such threads.

"함수(Function)"는 프로그램 내에서 어떤 특정한 작업을 독립적으로 수행하여 결과를 유도해내는 규격화된 서브루틴(Subroutine)과 같은 하나의 단위를 일컫는다. 함수에 요구하는 인자(Argument)를 전달하면, 함수는 그 인자에 대한 결과값을 돌려준다(return). "Function" refers to a unit, such as a standardized subroutine that performs a specific task in a program independently to produce a result. If you pass an argument to the function, the function returns the result for that argument.

도 1은 본 발명의 일 실시예에 따른 멀티 쓰레드 기반 센서 운영체제 환경에서의 스택 할당 방법을 개략적으로 설명하기 위한 흐름도이다.1 is a flowchart illustrating a stack allocation method in a multi-threaded sensor operating system environment according to an embodiment of the present invention.

도시된 바와 같이, 쓰레드의 작업 수행중에 함수가 호출될 때마다 해당 함수에 의해 사용될 스택 영역을 할당한다(110). As shown, whenever a function is called while the thread is executing, the stack area allocated by the function is allocated (110).

본 발명의 일실시예에서, 할당될 스택 영역의 크기는 해당 함수에 의해 사용되는 지역 변수의 크기 및 함수 인자들(Arguments)의 개수 등에 기반하여 예측될 수 있다. 또한, 프로그램의 컴파일시에 컴파일러에 의해 제공되는 어셈블리 코드를 분석함으로써 함수에 의해 사용될 스택 영역 크기를 좀더 정확히 예측할 수 있다. 단지 C 언어 수준에서의 프로그램 코드로는 실제 임베디드 시스템(Embedded System) 혹은 센서 노드에서 동작하는 기계 코드 수준에서의 각 함수별 스택 크기의 증가 및 감소량을 알 수 없으므로, 해당 함수에 대응하는 어셈블리 코드를 분석함으로써 스택 영역 크기를 좀더 정확히 예측할 수 있다. 어셈블리 코드는 기계 코드를 어셈블리 언어로 치환해 놓은 형태로서, 이를 분석함으로써 각 함수별 스택 영역의 사용량을 정확히 알아낼 수 있다. In an embodiment of the present invention, the size of the stack area to be allocated may be estimated based on the size of the local variable and the number of function arguments used by the corresponding function. In addition, by analyzing the assembly code provided by the compiler when the program is compiled, it is possible to more accurately predict the size of the stack area to be used by the function. The program code at the C language level does not show the increase and decrease of the stack size of each function at the machine code level operating in the embedded system or sensor node. By analyzing, the stack area size can be predicted more accurately. Assembly code replaces machine code with assembly language. By analyzing this, the usage of stack area of each function can be accurately determined.

각 함수별 스택 사용량의 측정 결과는 별도의 파일에 기록해 두고, 이 정보를 바탕으로 매 번 함수 호출 시점에 새로운 스택 영역을 할당할 수 있다. The result of measuring stack usage by each function is recorded in a separate file, and based on this information, a new stack area can be allocated at each function call.

따라서, 본 발명에 따른 스택 할당 방법에 따르면 스택 오버플로우(Overflow)를 방지할 수 있다. Therefore, according to the stack allocation method according to the present invention, it is possible to prevent stack overflow.

상기 할당된 스택공간을 이용하여 해당 함수의 실행이 종료되면, 사용된 스 택 영역을 반납한다(단계 120). When execution of the function is terminated using the allocated stack space, the used stack area is returned (step 120).

이하, 도 2를 참조하여 본 발명의 일실시예에 따른 스택 영역 할당 방법을 좀더 구체적으로 살펴본다. Hereinafter, a stack area allocation method according to an embodiment of the present invention will be described in more detail with reference to FIG. 2.

도 2를 참조하면, 우선, 멀티 쓰레드 기반 센서 운영체제 환경에서 실행될 쓰레드가 생성된다(210). 전술한 바와 같이, 센서 노드에서 동작할 센서 운영체제는 센싱, 통신 및 변환 등의 다수의 작업을 실시간으로 처리하기 위한 복수개의 쓰레드를 동시에 실행시킬 필요가 있으므로, 1개 이상의 쓰레드가 생성될 수 있다. Referring to FIG. 2, first, a thread to be executed in a multi-threaded sensor operating system environment is created (210). As described above, since the sensor operating system to operate in the sensor node needs to simultaneously execute a plurality of threads for processing a plurality of tasks such as sensing, communication, and transformation in real time, one or more threads may be generated.

단계(220)에서, 상기 생성된 쓰레드의 작업 수행 중에 함수가 호출될 경우 해당 함수에 의해 사용될 스택 영역을 할당한다. 스택 영역 크기의 예측 방법에 대해서는 도 1을 참조하여 이미 설명한 바 있다. 즉, 호출될 함수에 의해 사용될 지역 변수의 크기 및 함수 인자들의 개수 등에 기반하여 스택 영역의 할당량을 예측하거나, 상기 함수에 대응하는 어셈블리 코드를 분석함으로써 스택 영역 크기를 좀더 정확히 예측할 수 있다. 다음, 상기 단계(230)에서 할당된 스택 영역을 가리키도록 스택 포인터(Stack Pointer)를 이동시킨다. 스택 포인터를 이동시키기 이전에, 추후 복원을 위해 현재 스택 포인터를 저장해둔다. In step 220, a stack area to be used by the function is allocated when a function is called while performing the work of the created thread. The prediction method of the stack region size has been described with reference to FIG. 1. That is, the stack area size can be predicted more accurately by estimating the stack area allocation based on the size of the local variable to be used by the function to be called and the number of function arguments, or by analyzing the assembly code corresponding to the function. Next, the stack pointer is moved to point to the stack area allocated in step 230. Before moving the stack pointer, save the current stack pointer for later restoration.

다음, 단계(240)에서 함수의 인자 및 리턴 주소(Return Address)를 스택에 저장한다. Next, in step 240, the argument and the return address of the function are stored on the stack.

이후에, 함수가 호출되어 실행되고(250), 함수의 작업이 종료되면 해당 함수를 다시 리턴한다(260).Thereafter, the function is called and executed (250), and when the operation of the function is finished, the function returns again (260).

마지막으로, 상기 스택 포인터를 복원한 후(270), 상기 단계(S200)에서 할당되었던 스택 영역을 반납한다(280).Finally, after restoring the stack pointer (270), the stack area allocated in step S200 is returned (280).

하기의 표 1에서는 종래 기술의 정적인 스택 할당 방법과 본 발명의 일 실시예에 따른 동적인 스택 할당 방법을 기능별로 비교하고 있다.Table 1 below compares the static stack allocation method of the prior art and the dynamic stack allocation method according to an embodiment of the present invention by function.

종래 기술Prior art 본 발명The present invention 스택 할당 시점Stack allocation 쓰레드 생성 시When creating a thread 함수 호출 시When a function is called 스택 할당 크기Stack allocation size 정적silence 동적dynamic 함수 호출 방법How to call a function 일반적인 함수 호출 방법과 동일함Same as normal function call 스택 할당 후 함수 호출, 함수 종료 시 스택 반납Function call after stack allocation, stack return at function exit 스택 할당 비용Stack allocation cost 단 한번 발생Only occurs once 여러 번 발생 가능Can occur multiple times 스택 영역 효율Stack Area Efficiency 낮음lowness 높음height 최대 쓰레드 수Maximum number of threads 스택 크기에 반비례Inversely proportional to stack size 함수 중첩 수준에 반비례Inverse to function nesting level 스택 오버플로우Stack overflow 발생 가능Possible 발생하지 않음Does not occur

본 발명의 일 실시예에 따른 스택 할당 방법의 경우, 쓰레드가 사용할 스택 영역이 함수 호출 시마다 할당되므로, 수행 시간의 측면에서 잠재적인 부하가 발생할 수 있다. 그러나, 전체 스택 영역의 효율성을 증진시킬 수 있고, 최대 쓰레드 생성 수가 스택의 크기가 아닌 함수의 중첩 수준에 반비례하므로, 종래 기술의 스택기반 쓰레드 할당 방법을 사용하는 경우보다 더 많은 쓰레드를 생성시킬 수 있게 된다.In the stack allocation method according to an embodiment of the present invention, since a stack area to be used by a thread is allocated every function call, a potential load may occur in terms of execution time. However, it is possible to improve the efficiency of the entire stack area, and because the maximum number of threads is inversely proportional to the level of nesting of the function rather than the size of the stack, more threads can be created than with the conventional stack-based thread allocation method. Will be.

도 3은 종래 기술의 정적인 스택 할당 방법과 본 발명의 일 실시예에 따른 동적인 스택 할당 방법을 비교하기 위한 스택 영역의 할당 예를 나타낸 도면이다. 구체적으로는, 3개의 쓰레드(Thread 1, Thread 2 및 Thread 3)가 각각 최소 2에서 최대 4개의 함수를 중첩 호출할 경우에 종래 기술과 본원 발명에 따른 전체 시스템의 메모리의 사용 예를 보인다. 3 is a diagram illustrating an example of allocation of a stack area for comparing a static stack allocation method of the related art with a dynamic stack allocation method according to an embodiment of the present invention. Specifically, when three threads (Thread 1, Thread 2 and Thread 3) each call at least two to at most four functions, an example of using the memory of the entire system according to the prior art and the present invention is shown.

도 3(a)는 종래 기술에 따라 각각의 쓰레드에 대하여 스택 영역(T1, T2, T3)이 할당되는 경우에 스택 영역의 낭비가 발생함을 보여준다. 반면에, 도 3(b)는 본 발명에 따라 각 스레드의 함수 호출시마다 스택 영역이 할당되는 경우에는 나머지 영역이 자유 영역으로 보존됨으로써 스택영역의 낭비가 발생하지 않음을 보여준다.3 (a) shows that waste of the stack area occurs when the stack areas T1, T2, and T3 are allocated to each thread according to the related art. On the other hand, Figure 3 (b) shows that when the stack area is allocated for each function call of each thread according to the present invention, the remaining area is preserved as a free area so that the waste of the stack area does not occur.

즉, 본 발명의 일 실시예에 따른 동적인 스택 할당 방법을 사용할 경우, 스택 영역의 공간 낭비를 최소화시킬 수 있으며, 이를 통하여 전체 스택 사용량을 상당 부분 감소시킬 수 있다.That is, when using the dynamic stack allocation method according to an embodiment of the present invention, it is possible to minimize the waste of space in the stack area, thereby significantly reducing the overall stack usage.

도 4는 본 발명의 일 실시예에 따른 멀티 쓰레드 기반 센서 운영체제 환경에서의 스택 할당 방법과 종래의 정적인 스택 할당 방법을 비교하기 위한 스택 할당량을 나타낸 그래프로서, 본 발명의 일 실시예에 따른 동적인 스택 할당 방법을 사용하는 것이 매우 공간 효율적으로 동작함을 확인할 수 있다.4 is a graph illustrating stack allocation for comparing a stack allocation method and a conventional static stack allocation method in a multi-threaded sensor operating system environment according to an embodiment of the present invention. You can see that using an in-stack allocation method works very space efficiently.

전술한 바와 같이, 본 발명의 일 실시예에 따른 멀티 쓰레드 기반 센서 운영체제 환경에서의 스택 할당 방법은, 쓰레드가 필요로 하는 만큼의 스택 영역의 할당을 동적으로 수행한다. 이는 각 쓰레드의 매 함수 호출마다 이루어지며, 함수가 종료할 때에는 스택을 반납하여 다른 쓰레드가 그 공간을 재사용할 수 있도록 한다. 본 발명의 스택할당 방법을 사용하면, 메모리 공간의 할당 및 반납의 시간상의 부하는 존재하지만, 전체 메모리 공간을 효율적으로 사용할 수 있게 된다.As described above, the stack allocation method in a multi-threaded sensor operating system environment according to an embodiment of the present invention dynamically allocates as many stack regions as a thread requires. This is done for each function call in each thread, and when the function exits, it returns the stack so that other threads can reuse that space. Using the stack allocation method of the present invention, although there is a time load of allocating and returning memory space, the entire memory space can be efficiently used.

따라서, 공간 제약적인 무선 센서 운영체제에서, 멀티 쓰레드 기반 태스크 관리 기법을 사용할 경우의 메모리 부족 문제를 쉽게 해결해줄 수 있다. 또한, 스택 오버플로우(Overflow) 문제도 미연에 방지할 수 있게 되므로, 메모리 관리 유닛(Memory Management Unit, MMU)이 없는 무선 센서 노드와 같은 초소형 컴퓨터 시스템에서 매우 유용하게 쓰일 수 있다.Therefore, in the space-constrained wireless sensor operating system, it is easy to solve the memory shortage problem when using the multi-threaded task management technique. In addition, stack overflow problems can be prevented, which can be very useful in microcomputer systems such as wireless sensor nodes without a memory management unit (MMU).

전술한 본 발명은 하나 이상의 제조물상에 구현된 하나 이상의 컴퓨터 판독가능 매체로서 제공될 수 있다. 제조물은, 플로피 디스크, 하드 디스크, CD ROM, 플래시 메모리 카드,PROM, RAM, ROM, 또는 자기 테이프를 들 수 있다. 일반적으로, 컴퓨터 판독가능 프로그램은 임의의 프로그래밍 언어로 구현될 수 있다. 사용될 수 있는 언어의 일부 예에는 C, C++, 또는 JAVA가 포함된다. The invention described above may be provided as one or more computer readable media embodied on one or more articles of manufacture. The article of manufacture may be a floppy disk, a hard disk, a CD ROM, a flash memory card, a PROM, a RAM, a ROM, or a magnetic tape. Generally, computer readable programs can be implemented in any programming language. Some examples of languages that can be used include C, C ++, or JAVA.

이상에서, 본 발명에 따른 실시예들에 대하여 설명하였지만, 본 발명은 이에 한정되는 것이 아니고 특허청구범위와 발명의 상세한 설명 및 첨부한 도면의 범위 안에서 여러 가지로 변형하여 실시하는 것이 가능하고 이 또한 본 발명에 속한다.In the above, embodiments of the present invention have been described, but the present invention is not limited thereto, and various modifications and changes can be made within the scope of the claims and the detailed description of the invention and the accompanying drawings. Belongs to the present invention.

이상에서 설명한 바와 같은 본 발명에 따르면, 쓰레드가 필요로 하는 만큼의 스택 영역의 할당을 동적으로 수행함으로써, 기존의 정적인 쓰레드 스택 할당 방법을 사용하는 것보다 메모리 공간의 사용량을 상당히 절감시킬 수 있으며, 스택 오버플로우 문제도 미연에 방지할 수 있게 되므로, 메모리 관리 유닛(MMU)이 없는 무선 센서 노드와 같은 초소형 컴퓨터 시스템에서 매우 유용하게 쓰일 수 있는 이점이 있다.According to the present invention as described above, by dynamically allocating as much stack area as the thread requires, it is possible to significantly reduce the memory space usage than using the conventional static thread stack allocation method. In addition, stack overflow problems can be prevented, which can be very useful in a small computer system such as a wireless sensor node without a memory management unit (MMU).

Claims (10)

멀티 쓰레드 기반 센서 운영체제 환경에서의 동적 스택 할당 방법에 있어서, A dynamic stack allocation method in a multi-threaded sensor operating system environment, 쓰레드의 작업 수행 중에 함수의 호출 시마다 상기 호출된 함수에 의해 사용될 스택 영역을 동적으로 할당하는 단계와,Dynamically allocating a stack region to be used by the called function each time a function is called while executing a thread's work; 상기 함수의 실행이 종료되면 상기 할당된 스택 영역을 반납하는 단계Returning the allocated stack area when execution of the function is terminated. 를 포함하는 멀티 쓰레드 기반 센서 운영체제 환경에서의 동적 스택 할당 방법.Dynamic stack allocation method in a multi-threaded sensor operating system environment including a. 제1항에 있어서, The method of claim 1, 상기 함수에 의해 사용될 지역 변수의 크기 및 함수 인자의 개수에 기반하여 상기 할당될 스택 영역의 크기를 예측하는 단계를 더 포함하는 멀티 쓰레드 기반 센서 운영체제 환경에서의 동적 스택 할당 방법.Estimating the size of the stack area to be allocated based on the size of a local variable to be used by the function and the number of function arguments. 제1항에 있어서, The method of claim 1, 상기 함수에 대응하는 어셈블리 코드를 분석함으로써 상기 할당될 스택 영역의 크기를 예측하는 단계를 더 포함하는 멀티 쓰레드 기반 센서 운영체제 환경에서의 동적 스택 할당 방법.Estimating the size of the stack area to be allocated by analyzing assembly code corresponding to the function. 제2항 또는 제3항에 있어서, The method according to claim 2 or 3, 상기 예측된 스택 영역의 크기 정보를 저장하는 단계를 더 포함하고, Storing size information of the predicted stack area; 상기 저장된 스택 영역의 크기 정보에 기반하여 스택 영역이 할당되는 멀티 쓰레드 기반 센서 운영체제 환경에서의 동적 스택 할당 방법.A dynamic stack allocation method in a multi-threaded sensor operating system environment in which a stack region is allocated based on the size information of the stored stack region. 멀티 쓰레드 기반 센서 운영체제 환경에서의 동적 스택 할당 방법에 있어서, A dynamic stack allocation method in a multi-threaded sensor operating system environment, 쓰레드의 작업 수행 중에 함수가 호출되는 경우에 상기 호출된 함수에 의해 사용될 스택 영역을 할당하는 단계와,Allocating a stack area to be used by the called function when the function is called during the execution of a thread; 상기 할당된 스택 영역을 가리키도록 스택 포인터를 이동시키는 단계와,Moving a stack pointer to point to the allocated stack area; 상기 함수의 인자 및 리턴 주소를 상기 스택 영역에 저장하는 단계와,Storing the argument and return address of the function in the stack area; 상기 함수의 실행이 종료되면, 상기 함수를 리턴하는 단계와,When the execution of the function is finished, returning the function; 상기 스택 포인터를 복원하고, 상기 할당된 스택 영역을 반납하는 단계Restoring the stack pointer and returning the allocated stack area 를 포함하는 멀티 쓰레드 기반 센서 운영체제 환경에서의 동적 스택 할당 방법.Dynamic stack allocation method in a multi-threaded sensor operating system environment including a. 제5항에 있어서, The method of claim 5, 상기 함수에 의해 사용될 지역 변수의 크기 및 함수 인자의 개수에 기반하여 상기 할당될 스택 영역의 크기를 예측하는 단계를 더 포함하는 멀티 쓰레드 기반 센서 운영체제 환경에서의 동적 스택 할당 방법.Estimating the size of the stack area to be allocated based on the size of a local variable to be used by the function and the number of function arguments. 제5항에 있어서, The method of claim 5, 상기 함수에 대응하는 어셈블리 코드를 분석함으로써 상기 할당될 스택 영역의 크기를 예측하는 단계를 더 포함하는 멀티 쓰레드 기반 센서 운영체제 환경에서의 동적 스택 할당 방법.Estimating the size of the stack area to be allocated by analyzing assembly code corresponding to the function. 제6항 또는 제7항에 있어서, The method according to claim 6 or 7, 상기 예측된 스택 영역의 크기 정보를 저장하는 단계를 더 포함하고, Storing size information of the predicted stack area; 상기 저장된 스택 영역의 크기 정보에 기반하여 스택 영역이 할당되는 멀티 쓰레드 기반 센서 운영체제 환경에서의 동적 스택 할당 방법.A dynamic stack allocation method in a multi-threaded sensor operating system environment in which a stack region is allocated based on the size information of the stored stack region. 제1항 또는 제5항에 따른 동적 스택 할당 방법을 수행하기 위한 컴퓨터 프로그램이 기록된 컴퓨터 판독가능 기록매체.A computer-readable recording medium having recorded thereon a computer program for performing the dynamic stack allocation method according to claim 1. 제9항에 있어서, 상기 컴퓨터 프로그램은 제한된 크기의 메모리를 갖는 센서 노드에서 수행되는 컴퓨터 판독가능 기록매체.10. The computer program product of claim 9, wherein the computer program is executed at a sensor node having a limited size of memory.
KR1020070029595A 2006-12-12 2007-03-27 Method for allocation stack in multi-threaded sensor operating systems environment KR100846451B1 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
US11/753,023 US20080140979A1 (en) 2006-12-12 2007-05-24 Method of allocating stack in multi-threaded sensor operating system environment

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
KR1020060126390 2006-12-12
KR20060126390 2006-12-12

Publications (2)

Publication Number Publication Date
KR20080054324A true KR20080054324A (en) 2008-06-17
KR100846451B1 KR100846451B1 (en) 2008-07-16

Family

ID=39801367

Family Applications (1)

Application Number Title Priority Date Filing Date
KR1020070029595A KR100846451B1 (en) 2006-12-12 2007-03-27 Method for allocation stack in multi-threaded sensor operating systems environment

Country Status (1)

Country Link
KR (1) KR100846451B1 (en)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2012118268A2 (en) * 2011-02-28 2012-09-07 ㈜지노게임즈 Multi-thread processing system using a multi-virtual machine, and method therefor
US8478956B2 (en) 2009-11-13 2013-07-02 Samsung Electronics Co., Ltd. Computing system and method controlling memory of computing system
KR101378058B1 (en) * 2012-03-30 2014-03-27 국방과학연구소 Dynamic memory managing methof in embedded system
KR20190071208A (en) * 2017-12-14 2019-06-24 현대자동차주식회사 Method and apparatus for monitoring memory and showing its usage for use in electrical control device
KR20230006109A (en) * 2021-07-02 2023-01-10 한국과학기술원 Method And Apparatus for Generating Proxy Contract

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR100304355B1 (en) * 1997-12-17 2001-09-24 이계철 Stack management method for real-time system

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8478956B2 (en) 2009-11-13 2013-07-02 Samsung Electronics Co., Ltd. Computing system and method controlling memory of computing system
WO2012118268A2 (en) * 2011-02-28 2012-09-07 ㈜지노게임즈 Multi-thread processing system using a multi-virtual machine, and method therefor
WO2012118268A3 (en) * 2011-02-28 2012-10-26 ㈜지노게임즈 Multi-thread processing system using a multi-virtual machine, and method therefor
KR101378058B1 (en) * 2012-03-30 2014-03-27 국방과학연구소 Dynamic memory managing methof in embedded system
KR20190071208A (en) * 2017-12-14 2019-06-24 현대자동차주식회사 Method and apparatus for monitoring memory and showing its usage for use in electrical control device
KR20230006109A (en) * 2021-07-02 2023-01-10 한국과학기술원 Method And Apparatus for Generating Proxy Contract

Also Published As

Publication number Publication date
KR100846451B1 (en) 2008-07-16

Similar Documents

Publication Publication Date Title
CN1306399C (en) Virtual machine for network processor
JP5868429B2 (en) Method, computer program product, and apparatus for progressively unloading classes using a region-based garbage collector
US8453132B2 (en) System and method for recompiling code based on locality domain and thread affinity in NUMA computer systems
US9600305B2 (en) Code partitioning for enhanced performance
US10572181B2 (en) Multiple stage garbage collector
KR100846451B1 (en) Method for allocation stack in multi-threaded sensor operating systems environment
KR20090108868A (en) Virtual machine management system and method for managing processor resources thereof
US20140115291A1 (en) Numa optimization for garbage collection of multi-threaded applications
EP3577565B1 (en) Garbage collector
JP2015519646A (en) Modified JVM with multi-tenant application domain and memory management
US7647482B2 (en) Methods and apparatus for dynamic register scratching
Diener et al. Improving the memory access locality of hybrid MPI applications
US20080140979A1 (en) Method of allocating stack in multi-threaded sensor operating system environment
US6959430B2 (en) Specialized heaps for creation of objects in object-oriented environments
CN108139929B (en) Task scheduling apparatus and method for scheduling a plurality of tasks
US11954419B2 (en) Dynamic allocation of computing resources for electronic design automation operations
US7120775B2 (en) Inter-procedural allocation of stacked registers for a processor
US20050216900A1 (en) Instruction scheduling
Higuera-Toledano et al. Analyzing the performance of memory management in RTSJ
Mauroner et al. StackMMU: Dynamic stack sharing for embedded systems
JP2003256215A (en) Program conversion method, data processor using the same, and program
De Sensi et al. State-aware concurrency throttling
KR102622448B1 (en) Operating system performance interference preventing apparatus of hypervisor system
US20240134659A1 (en) Java bytecode injection methods and apparatuses, electronic devices, and storage media
Kim et al. Efficient reuse of local regions in memory-limited mobile devices

Legal Events

Date Code Title Description
A201 Request for examination
E902 Notification of reason for refusal
E701 Decision to grant or registration of patent right
GRNT Written decision to grant
LAPS Lapse due to unpaid annual fee