KR102384249B1 - Method for processing data by use of multi-threads on a web browser - Google Patents

Method for processing data by use of multi-threads on a web browser Download PDF

Info

Publication number
KR102384249B1
KR102384249B1 KR1020170096216A KR20170096216A KR102384249B1 KR 102384249 B1 KR102384249 B1 KR 102384249B1 KR 1020170096216 A KR1020170096216 A KR 1020170096216A KR 20170096216 A KR20170096216 A KR 20170096216A KR 102384249 B1 KR102384249 B1 KR 102384249B1
Authority
KR
South Korea
Prior art keywords
data
thread
message queue
transmitting
web
Prior art date
Application number
KR1020170096216A
Other languages
Korean (ko)
Other versions
KR20190012742A (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 KR1020170096216A priority Critical patent/KR102384249B1/en
Publication of KR20190012742A publication Critical patent/KR20190012742A/en
Application granted granted Critical
Publication of KR102384249B1 publication Critical patent/KR102384249B1/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
    • G06F9/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4843Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
    • G06F9/4881Scheduling strategies for dispatcher, e.g. round robin, multi-level priority queues
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/20Servers specifically adapted for the distribution of content, e.g. VOD servers; Operations thereof
    • H04N21/23Processing of content or additional data; Elementary server operations; Server middleware
    • H04N21/236Assembling of a multiplex stream, e.g. transport stream, by combining a video stream with other content or additional data, e.g. inserting a URL [Uniform Resource Locator] into a video stream, multiplexing software data into a video stream; Remultiplexing of multiplex streams; Insertion of stuffing bits into the multiplex stream, e.g. to obtain a constant bit-rate; Assembling of a packetised elementary stream
    • H04N21/23605Creation or processing of packetized elementary streams [PES]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/60Network structure or processes for video distribution between server and client or between remote clients; Control signalling between clients, server and network components; Transmission of management data between server and client, e.g. sending from server to client commands for recording incoming content stream; Communication details between server and client 
    • H04N21/63Control signaling related to video distribution between client, server and network components; Network processes for video distribution between server and clients or between remote clients, e.g. transmitting basic layer and enhancement layers over different transmission paths, setting up a peer-to-peer communication via Internet between remote STB's; Communication protocols; Addressing
    • H04N21/643Communication protocols
    • H04N21/6437Real-time Transport Protocol [RTP]

Abstract

본 발명은 웹 브라우저 상에서 멀티 쓰레드로 데이터를 처리하는 방법에 관한 발명이다. 상기 멀티 쓰레드는 메인 쓰레드인 제1 쓰레드와 하위 쓰레드인 제2 쓰레드를 포함한다. 본 발명에 따르면 제2 쓰레드의 메시지 큐의 오버플로우 발생 없이 제1 쓰레드가 제2 쓰레드로 데이터를 전달하며 웹 브라우저 상에서 데이터를 처리하는 것이 가능하다. 따라서 웹 브라우저 상에서 멀티 쓰레드로 안정적으로 데이터를 처리하는 것이 가능하고, 이를 통해 웹 브라우저 상에서 멀티 쓰레드로 데이터를 처리하는 장치의 신뢰성을 높일 수 있다.The present invention relates to a method for processing data in multiple threads on a web browser. The multi-thread includes a first thread that is a main thread and a second thread that is a lower thread. According to the present invention, it is possible for the first thread to transfer data to the second thread without overflow of the message queue of the second thread and to process the data on the web browser. Therefore, it is possible to stably process data with multi-threads on the web browser, and through this, the reliability of a device that processes data with multi-threads on the web browser can be increased.

Description

웹 브라우저 상에서 멀티 쓰레드를 이용하여 데이터를 처리하는 방법{Method for processing data by use of multi-threads on a web browser}Method for processing data by use of multi-threads on a web browser

본 발명은 웹 브라우저 상에서 데이터를 처리하는 방법에 관한 것으로서, 보다 상세하게는 오버플로우(overflow)의 발생 없이 복수의 쓰레드 간에 데이터를 전달하며 데이터를 처리하는 방법에 관한 것이다.The present invention relates to a method of processing data on a web browser, and more particularly, to a method of processing data while transferring data between a plurality of threads without overflow.

웹 브라우저에서 사용되는 프로그래밍 언어인 자바스크립트는 HTML, CSS와 함께 웹 페이지를 구성하는 요소의 하나이다. HTML이 웹 페이지의 구성을, CSS가 웹 페이지의 디자인을 담당한다면, 자바스크립트는 웹 페이지의 동작을 담당한다. JavaScript, a programming language used in web browsers, is one of the elements that compose web pages along with HTML and CSS. While HTML is responsible for the composition of the web page and CSS is responsible for the design of the web page, JavaScript is responsible for the operation of the web page.

자바스크립트는 객체 기반의 스크립트 언어(scripting language)이다. 그리고 자바스크립트는 동적 언어이기 때문에 자바스크립트를 사용할 경우 정적인 HTML과 달리 동적인 웹 페이지를 구현할 수 있다. 또한 자바스크립트는 다른 언어에 비해 문법이 간단하여 다수의 프로그래머들이 용이하게 사용할 수 있다. 이러한 자바스크립트의 특징들 외에도 중요한 특징이 하나 있는데, 자바스크립트는 싱글 쓰레드 기반이라는 것이다. JavaScript is an object-based scripting language. And since JavaScript is a dynamic language, when JavaScript is used, a dynamic web page can be implemented unlike static HTML. Also, JavaScript has a simpler syntax compared to other languages, so many programmers can easily use it. In addition to these characteristics of JavaScript, there is one important characteristic, which is that JavaScript is single-threaded.

싱글 쓰레드란 하나의 프로세스를 하나의 쓰레드로 수행하는 것을 뜻한다. 자바스크립트는 싱글 쓰레드로 동작하다 보니 여러 개의 작업을 동시에 처리하지 못한다. 이로 인해 종래에는 스크립트가 동작하는 동안에는 스크립트가 완료될 때까지 웹 페이지가 반응을 하지 못했다. 이에 개발자들은 setTimeout, setInterval, XMLHttpRequest, 그리고 이벤트 핸들러(event handler) 등을 통해 스크립트의 동시 실행을 모방하고자 하였으나 자바스크립트의 싱글 쓰레드 특성을 근본적으로 해결하는 방법은 되지 못하였다.Single-threading means that one process is executed as one thread. Since JavaScript operates as a single thread, it cannot process multiple tasks at the same time. For this reason, conventionally, while the script is operating, the web page does not respond until the script is completed. Accordingly, the developers tried to imitate the simultaneous execution of scripts through setTimeout, setInterval, XMLHttpRequest, and event handlers, but it was not possible to fundamentally solve the single-threading characteristic of JavaScript.

이러한 자바스크립트의 싱글 쓰레드 특성을 극복하기 위해 고안된 것이 웹 워커이다. 웹 워커는 HTML 페이지에서 백그라운드로 동작하는 스크립트로, World Wide Web Consortium(W3C)와 Web Hypertext Application Technology Working Group(WHATWG)에 의해 개발되었다. 웹 워커는 크롬 4.0, 인터넷 익스플로러 10.0, 파이어폭스 3.5, 사파리 4.0, 오페라 11.5, 버전부터 전적으로 지원되고 있다. 또한 iOS 5, Android 2.1부터 지원되기 시작하였으며 Android의 경우 2.2-4.3버전에서는 지원이 중단되었다가 4.4 버전부터 다시 지원되고 있다. Web workers are designed to overcome the single-threaded characteristics of JavaScript. Web Worker is a script that runs in the background on an HTML page, and was developed by the World Wide Web Consortium (W3C) and the Web Hypertext Application Technology Working Group (WHATWG). Web Worker is fully supported from Chrome 4.0, Internet Explorer 10.0, Firefox 3.5, Safari 4.0, Opera 11.5, and later. In addition, it started to be supported from iOS 5 and Android 2.1, and in the case of Android, support was stopped in versions 2.2-4.3 and is supported again from version 4.4.

웹 워커는 웹 페이지의 백그라운드에서 동작하기 때문에 웹 페이지에 영향을 미치지 않는다. 다시 말하면, 웹 페이지에서 웹 워커를 생성할 때마다 자바스크립트를 실행할 수 있는 고유의 쓰레드를 생성하기 때문에 웹 워커는 웹 페이지와 독립된 쓰레드로 동작하게 되고, 웹 페이지는 웹 워커에서 실행하는 프로세스에 영향을 받지 않은 채로 스크립트를 실행할 수 있다.Since the web worker runs in the background of the web page, it does not affect the web page. In other words, whenever a web worker is created in a web page, it creates its own thread that can execute JavaScript, so the web worker operates as a separate thread from the web page, and the web page affects the process running in the web worker. You can run the script without receiving the .

웹 페이지와 웹 워커가 멀티 쓰레드로 웹 브라우저에서 작업을 수행하기 위해 웹 페이지와 웹 워커간 간에 데이터의 송수신이 이루어진다. 이때 사용되는 것이 postMessage 메쏘드(method)와 onMessage 이벤트 핸들러이다. postMessage 메쏘드는 웹 페이지에서 웹 워커로 데이터를 전달할 때 사용되고, onMessage 이벤트 핸들러는 웹 워커에서 데이터를 수신할 때 사용된다. 이와 반대로 웹 워커에서 웹 페이지로 데이터를 전달할 때에도 마찬가지의 방법이 사용된다. Data is transmitted and received between the web page and the web worker so that the web page and the web worker perform a task in the web browser with multi-threads. In this case, the postMessage method and onMessage event handler are used. The postMessage method is used to pass data from the web page to the web worker, and the onMessage event handler is used to receive data from the web worker. Conversely, the same method is used when passing data from a web worker to a web page.

웹 페이지로부터 postMessage를 통해 전달된 데이터는 웹 워커의 메시지 큐(message queue)에 저장된다. 웹 워커에서 메시지 큐에 저장된 데이터는 콜 스택(call stack)으로 이동되어 처리된다. 그런데 콜 스택으로 이동하는 데이터의 개수에 비하여 과도한 수의 데이터가 웹 페이지에서 웹 워커로 전달되는 경우 병목현상으로 인해 메시지 큐에 오버플로우가 발생할 수 있다. Data delivered through postMessage from the web page is stored in the message queue of the web worker. Data stored in the message queue in the web worker is moved to the call stack and processed. However, if an excessive number of data is transferred from a web page to a web worker compared to the number of data moving to the call stack, the message queue may overflow due to a bottleneck.

웹 워커는 장시간 소요되는 작업을 백그라운드에서 수행하기위해 고안된 스크립트이다 보니, 웹 워커에 짧은 시간에 과도한 수의 데이터가 전달되어 메시지 큐에 오버플로우가 발생하는 것을 방지하는 장치는 마련되어 있지 않은 상황이다. 그러나 웹 워커는 영상처리 등 시간이 오래 걸리는 작업에만 반드시 사용되어야 하는 것은 아니다. 또한 영상처리에서도 영상 데이터가 작은 크기로 잘게 분할된 경우, 웹 페이지에서 웹 워커로 다수의 분할된 영상 데이터를 전달해야 하는 상황이 발생할 수 있다. Since the web worker is a script designed to perform a long-time task in the background, there is no device in place to prevent overflow of the message queue due to excessive data being delivered to the web worker in a short time. However, web workers do not necessarily have to be used only for time-consuming tasks such as image processing. Also, in image processing, when image data is divided into small pieces, a situation may arise in which a plurality of divided image data needs to be transmitted from a web page to a web worker.

웹 워커의 메시지 큐에 오버플로우가 발생하면 웹 워커에 의해 실행되고 있는 스크립트에 락(lock)이 걸리거나 또는 웹 브라우저가 동작하지 않는 상황까지 발생할 수 있다. 이는 실시간 영상 스트리밍 등 실시간으로 웹 브라우저 상에서 작업을 수행해야하는 경우에 치명적인 문제가 될 수 있다. 웹 브라우저에서 멀티 쓰레드로 작업을 수행하기 위해 고안된 웹 워커가 메시지 큐의 오버플로우로 인해 스크립트가 동작하지 않는 상황을 발생시켜서는 안될 것이며, 이에 웹 워커의 메시지 큐의 오버플로우 발생 없이 멀티 쓰레드로 데이터를 처리하는 방법이 요구된다.When the web worker's message queue overflows, the script being executed by the web worker may be locked or the web browser may not work. This can be a fatal problem when performing tasks on a web browser in real time, such as real-time video streaming. A web worker designed to perform multi-threaded tasks in a web browser should not cause a situation in which the script does not work due to an overflow of the message queue. A method of handling is required.

한국공개공보 제10-2014-0103038호Korean Publication No. 10-2014-0103038

본 발명이 해결하고자 하는 과제는, 웹 페이지와 웹 워커 간의 데이터 전달로 인해 웹 워커의 메시지 큐에 오버플로우가 발생하지 않는, 웹 브라우저 상의 데이터 처리 방법을 제공하는 것이다.An object of the present invention is to provide a method for processing data in a web browser in which an overflow does not occur in a message queue of a web worker due to data transfer between a web page and a web worker.

본 발명의 과제들은 이상에서 언급한 과제로 제한되지 않으며, 언급되지 않은 또 다른 과제들은 아래의 기재로부터 당업자에게 명확하게 이해될 수 있을 것이다.The problems of the present invention are not limited to the problems mentioned above, and other problems not mentioned will be clearly understood by those skilled in the art from the following description.

상기 과제를 해결하기 위한 본 발명의 실시예에 따른 데이터 처리 방법은, 웹 브라우저를 구비하는 데이터 처리 장치 상에서, 상기 웹 브라우저가 지원하는 쓰레드를 이용하여 적어도 하나의 프로세서에 의해 수행되는 데이터 처리 방법으로서, 상기 웹 브라우저 상에서 제1 쓰레드를 생성하는 단계; 상기 제1 쓰레드가 제2 쓰레드를 생성하는 단계; 상기 제1 쓰레드가 처리할 데이터를 상기 제2 쓰레드로 전달하는 단계; 상기 제2 쓰레드가 상기 전달된 데이터를 상기 제2 쓰레드의 메시지 큐에 저장하는 단계; 및 상기 제2 쓰레드가 상기 저장된 데이터를 처리하는 단계를 포함하되, 상기 처리할 데이터를 상기 제2 쓰레드로 전달하는 단계는, 상기 제1 쓰레드가 상기 제2 쓰레드의 메시지 큐의 현재 상태에 따라 상기 전달될 데이터의 개수를 조절하고, 상기 개수가 조절된 데이터를 상기 제2 쓰레드에 전달하는 단계를 포함할 수 있다.A data processing method according to an embodiment of the present invention for solving the above problems is a data processing method performed by at least one processor using a thread supported by the web browser on a data processing device having a web browser. , creating a first thread on the web browser; generating, by the first thread, a second thread; transmitting data to be processed by the first thread to the second thread; storing, by the second thread, the transferred data in a message queue of the second thread; and processing, by the second thread, the stored data, wherein the transferring the data to be processed to the second thread includes the first thread according to the current state of the message queue of the second thread. It may include adjusting the number of data to be transmitted, and transmitting the adjusted number of data to the second thread.

본 발명의 기타 구체적인 사항들은 상세한 설명 및 도면들에 포함되어 있다.Other specific details of the invention are included in the detailed description and drawings.

본 발명의 실시예들에 의하면 적어도 다음과 같은 효과가 있다.According to the embodiments of the present invention, there are at least the following effects.

상기 과제 해결 수단에 따르면 웹 페이지에서 웹 워커로 다수의 데이터 전송이 수반되는 작업을 웹 워커의 메시지 큐의 오버플로우 발생 없이 처리하는 것이 가능하다. 따라서 웹 워커에서 처리할 수 있는 작업의 범위가 넓어지는 효과가 있다.According to the above problem solving means, it is possible to process a task that involves transferring a large number of data from a web page to a web worker without overflow of the message queue of the web worker. Therefore, it has the effect of broadening the range of tasks that can be processed by the web worker.

또한 상기 과제 해결 수단에 따르면 웹 워커의 메시지 큐의 오버플로우 발생 없이 안정적으로 웹 워커를 사용할 수 있으므로 웹 브라우저 상에서 멀티 쓰레드로 데이터를 처리하는 장치의 신뢰성을 높일 수 있다. 이에 본 발명은 실시간 영상 처리 등 실시간성이 중요한 상황에서 매우 유용하게 사용될 것이다.In addition, according to the above problem solving means, since the web worker can be used stably without overflow of the message queue of the web worker, the reliability of a device that processes data in multiple threads on a web browser can be improved. Accordingly, the present invention will be very usefully used in situations where real-time performance is important, such as real-time image processing.

본 발명에 따른 효과는 이상에서 예시된 내용에 의해 제한되지 않으며, 더욱 다양한 효과들이 본 명세서 내에 포함되어 있다.The effect according to the present invention is not limited by the contents exemplified above, and more various effects are included in the present specification.

도 1은 웹 브라우저 상에서 동작하는 멀티 쓰레드를 나타낸다.
도 2는 제2 쓰레드(200)가 데이터를 처리하는 방법을 나타낸다.
도 3은 메시지 큐(210)에 인큐되는 데이터(211)와 디큐되는 데이터(212)를 나타낸다.
도 4는 메시지 큐(210)에 저장된 데이터(213)를 나타낸다.
도 5는 종래의 방식으로 제1 쓰레드(100)에서 제2 쓰레드(200)로 데이터를 전달하는 방법을 나타낸다.
도 6은 본 발명의 실시예인, 제1 쓰레드(100)에서 중간 데이터를 생성하여 제2 쓰레드(200)로 전달하는 방법을 나타낸다.
도 7은 제1 쓰레드(100)가 메시지 큐(210)의 상태에 따라 제2 쓰레드(200)로 데이터 개수를 조절하여 전달하는 방법에 대한 일 실시예를 나타낸다.
도 8은 제1 쓰레드(100)가 메시지 큐(210)의 상태에 따라 제2 쓰레드(200)로 데이터 개수를 조절하여 전달하는 방법에 대한 다른 실시예를 나타낸다.
도 9는 제1 쓰레드(100)가 메시지 큐(210)의 상태에 따라 제2 쓰레드(200)로 데이터 개수를 조절하여 전달하는 방법에 대한 또 다른 실시예를 나타낸다.
도 10은 멀티 쓰레드로 영상 데이터를 처리하는 장치를 나타낸다.
도 11은 RTP 데이터와 프레임 데이터를 나타낸다.
도 12는 본 발명의 실시예인, 영상처리장치를 나타낸다.
도 13은 RTP 데이터, RTPInt 데이터, 및 프레임 데이터를 나타낸다.
도 14는 RTP 데이터와 RTPInt 데이터가 인큐된 메시지 큐(210a, 210b)를 나타낸다.
1 shows a multi-thread operating on a web browser.
2 shows how the second thread 200 processes data.
3 shows data 211 enqueued in the message queue 210 and data 212 dequeued.
4 shows data 213 stored in a message queue 210 .
5 shows a method of transferring data from the first thread 100 to the second thread 200 in a conventional manner.
6 illustrates a method of generating intermediate data in the first thread 100 and transmitting the intermediate data to the second thread 200 according to an embodiment of the present invention.
7 shows an embodiment of a method in which the first thread 100 adjusts the number of data and transmits the data to the second thread 200 according to the state of the message queue 210 .
8 shows another embodiment of a method in which the first thread 100 adjusts the number of data and transmits the data to the second thread 200 according to the state of the message queue 210 .
9 shows another embodiment of a method in which the first thread 100 adjusts the number of data and transmits the data to the second thread 200 according to the state of the message queue 210 .
10 shows an apparatus for processing image data in a multi-threaded manner.
11 shows RTP data and frame data.
12 shows an image processing apparatus according to an embodiment of the present invention.
13 shows RTP data, RTPInt data, and frame data.
14 shows message queues 210a and 210b in which RTP data and RTPInt data are enqueued.

본 발명의 이점 및 특징, 그리고 그것들을 달성하는 방법은 첨부되는 도면과 함께 상세하게 후술되어 있는 실시예들을 참조하면 명확해질 것이다. 그러나 본 발명은 이하에서 개시되는 실시예들에 한정되는 것이 아니라 서로 다른 다양한 형태로 구현될 수 있으며, 단지 본 실시예들은 본 발명의 개시가 완전하도록 하고, 본 발명이 속하는 기술분야에서 통상의 지식을 가진 자에게 발명의 범주를 완전하게 알려주기 위해 제공되는 것이며, 본 발명은 청구항의 범주에 의해 정의될 뿐이다. 명세서 전체에 걸쳐 동일 참조 부호는 동일 구성 요소를 지칭한다.Advantages and features of the present invention and methods of achieving them will become apparent with reference to the embodiments described below in detail in conjunction with the accompanying drawings. However, the present invention is not limited to the embodiments disclosed below, but may be implemented in various different forms, and only these embodiments allow the disclosure of the present invention to be complete, and common knowledge in the art to which the present invention pertains It is provided to fully inform those who have the scope of the invention, and the present invention is only defined by the scope of the claims. Like reference numerals refer to like elements throughout.

다른 정의가 없다면, 본 명세서에서 사용되는 모든 용어(기술 및 과학적 용어를 포함)는 본 발명이 속하는 기술분야에서 통상의 지식을 가진 자에게 공통적으로 이해될 수 있는 의미로 사용될 수 있을 것이다. 또 일반적으로 사용되는 사전에 정의되어 있는 용어들은 명백하게 특별히 정의되어 있지 않는 한 이상적으로 또는 과도하게 해석되지 않는다.Unless otherwise defined, all terms (including technical and scientific terms) used herein may be used with the meaning commonly understood by those of ordinary skill in the art to which the present invention belongs. In addition, terms defined in a commonly used dictionary are not to be interpreted ideally or excessively unless clearly defined in particular.

본 명세서에서 사용된 용어는 실시예들을 설명하기 위한 것이며 본 발명을 제한하고자 하는 것은 아니다. 본 명세서에서, 단수형은 문구에서 특별히 언급하지 않는 한 복수형도 포함한다. 명세서에서 사용되는 "포함한다(comprises)" 및/또는 "포함하는(comprising)"은 언급된 구성요소 외에 하나 이상의 다른 구성요소의 존재 또는 추가를 배제하지 않는다.The terminology used herein is for the purpose of describing the embodiments and is not intended to limit the present invention. In this specification, the singular also includes the plural unless specifically stated otherwise in the phrase. As used herein, “comprises” and/or “comprising” does not exclude the presence or addition of one or more other components in addition to the stated components.

이하, 첨부된 도면을 참조하여 본 발명의 바람직한 실시예를 상세히 설명하기로 한다.Hereinafter, preferred embodiments of the present invention will be described in detail with reference to the accompanying drawings.

도 1은 웹 브라우저 상에서 동작하는 멀티 쓰레드를 나타낸다. 멀티 쓰레드는 자바스크립트로 작성된 스크립트를 실행하기 위한 쓰레드이며, 제1 쓰레드(100)와 제2 쓰레드(200)를 포함한다. 1 shows a multi-thread operating on a web browser. The multi-thread is a thread for executing a script written in JavaScript, and includes a first thread 100 and a second thread 200 .

제1 쓰레드(100)는 웹 브라우저 상에서 생성된 메인 쓰레드일 수 있다. 일반적으로 메인 쓰레드는 사용자 인터페이스 스크립트를 실행하는데 사용된다. 즉, 제1 쓰레드(100)는 사용자가 다양한 동작을 수행하도록 UI(User Interface) 기능을 수행하는 웹 페이지일 수 있다. 제2 쓰레드(200)는 제1 쓰레드(100)로부터 생성되는 하위 쓰레드로 웹 워커일 수 있다. 도 1에는 제2 쓰레드(200)가 하나의 쓰레드로 표현되어 있으나, 제2 쓰레드(200)는 복수의 쓰레드일 수 있다. The first thread 100 may be a main thread created on a web browser. Typically, the main thread is used to run user interface scripts. That is, the first thread 100 may be a web page that performs a user interface (UI) function so that the user performs various operations. The second thread 200 is a sub-thread generated from the first thread 100 and may be a web worker. Although the second thread 200 is represented as one thread in FIG. 1 , the second thread 200 may be a plurality of threads.

제1 쓰레드(100)는 아래 표 1의 방법으로 웹 워커를 사용하여 제2 쓰레드(200)를 생성할 수 있다.The first thread 100 may create the second thread 200 by using a web worker in the method shown in Table 1 below.

var myWorker = new Worker("worker.js");var myWorker = new Worker("worker.js");

웹 브라우저 상에서 메인 쓰레드인 제1 쓰레드(100)만 생성하여 사용한다면 자바스크립트의 싱글 쓰레드 특성으로 인해 실행중인 프로세스가 끝날 때까지 웹 페이지가 응답하지 않을 수 있다. 반면 웹 워커로 제2 쓰레드(200)를 생성하면, 제2 쓰레드(200)는 웹 페이지의 백그라운드에서 제1 쓰레드(100)와 독립된 쓰레드로 스크립트를 실행하기 때문에, 제1 쓰레드(100)는 제2 쓰레드(200)에서 프로세스가 완료되었는지 여부와 무관하게 자유로이 스크립트를 실행할 수 있다. If only the first thread 100, which is the main thread, is created and used on the web browser, the web page may not respond until the running process ends due to the single-thread characteristic of JavaScript. On the other hand, when the second thread 200 is created as a web worker, since the second thread 200 executes the script as a thread independent of the first thread 100 in the background of the web page, the first thread 100 is In the two threads 200 , the script can be freely executed regardless of whether the process has been completed.

웹 브라우저 상에서 제1 쓰레드(100) 및 제2 쓰레드(200)를 이용하여 프로세스를 수행하기 위해 쓰레드 간에 데이터 전달이 이루어질 수 있다. 이때 쓰레드 간의 데이터 전달은 postMessage 메쏘드(method)와 onMessage 이벤트 핸들러를 통해 이루어질 수 있는데, 이 경우 전달되는 데이터는 단일 변수만을 허용한다. postMessage 메쏘드는 제1 쓰레드(100)에서 제2 쓰레드(200)로 데이터를 전달하는데 이용되고 onMessage 이벤트 핸들러는 제2 쓰레드(200)에서 데이터를 수신하는데 이용된다. 제2 쓰레드(200)에서 제1 쓰레드(100)로의 데이터 전달도 마찬가지의 방식으로 이루어질 수 있다. postMessage 메쏘드와 onMessage 이벤트 핸들러를 이용하여 제1 쓰레드(100)와 제2 쓰레드(200)간에 데이터를 전달하는 방법은 아래의 표 2에 나타낸 바와 같다.In order to perform a process using the first thread 100 and the second thread 200 on the web browser, data transfer may be performed between threads. In this case, data transfer between threads can be done through the postMessage method and onMessage event handler. In this case, only a single variable is allowed for the transferred data. The postMessage method is used to transmit data from the first thread 100 to the second thread 200 , and the onMessage event handler is used to receive data from the second thread 200 . Data transfer from the second thread 200 to the first thread 100 may be performed in the same manner. A method of transferring data between the first thread 100 and the second thread 200 using the postMessage method and the onMessage event handler is shown in Table 2 below.

제1 쓰레드에서 제2 쓰레드로의 데이터 전달:
myWorker.postMessage(aMessage, transferList);

제1 쓰레드에서 데이터 수신:
myWorker.onmessage = function(event) {
value = event.data;
}

제2 쓰레드에서 제1 쓰레드로의 데이터 전달:
postMessage(aMessage, transferList);

제2 쓰레드에서 데이터 수신:
onmessage = function(event) {
value = event.data;
}
Passing data from first thread to second thread:
myWorker.postMessage(aMessage, transferList);

Receive data in first thread:
myWorker.onmessage = function(event) {
value = event.data;
}

Passing data from second thread to first thread:
postMessage(aMessage, transferList);

Receive data in second thread:
onmessage = function(event) {
value = event.data;
}

도 1에서 제1 쓰레드(100)는 제2 쓰레드(200)로 postMessage를 통해 처리할 데이터를 전달한다. 제2 쓰레드(200)는 제1 쓰레드(100)로부터 전달받은 데이터로 작업을 수행한다. 제2 쓰레드(200)가 작업을 수행하는 동안 제1 쓰레드(100)는 작업 결과가 수신되기를 기다리거나 또는 별도의 작업을 수행할 수 있다. 제2 쓰레드(200)는 작업이 완료되면 처리된 데이터를 postMessage를 통해 제1 쓰레드(100)로 전달한다. 이때, 제2 쓰레드(200)가 스크립트를 실행하는 도중임에도 불구하고 제1 쓰레드(100)가 프로세스를 실행할 수 있는 것은, 제2 쓰레드(200)가 백그라운드에서 독립된 쓰레드로 작업을 수행하기 때문이다. In FIG. 1 , the first thread 100 transmits data to be processed through postMessage to the second thread 200 . The second thread 200 performs an operation with data received from the first thread 100 . While the second thread 200 performs a task, the first thread 100 may wait for a task result to be received or may perform a separate task. When the work is completed, the second thread 200 delivers the processed data to the first thread 100 through postMessage. At this time, the reason that the first thread 100 can execute the process even though the second thread 200 is in the middle of executing the script is because the second thread 200 performs the task as an independent thread in the background.

이상 설명한 방법으로 웹 브라우저 상에서 데이터를 처리하는 장치는 제1 쓰레드(100), 제2 쓰레드(200) 그리고 postMessage를 사용하여 멀티 쓰레드로 데이터를 처리할 수 있다. The apparatus for processing data on a web browser by the method described above may process data in multi-threads using the first thread 100 , the second thread 200 , and postMessage.

도 2는 제2 쓰레드(200)가 데이터를 처리하는 방법을 나타낸다. 도 2에서 제2 쓰레드(200)는 제1 쓰레드(100)와 독립된 메시지 큐(210, message queue), 이벤트 루프(220, event loop) 그리고 콜 스택(230, call stack)을 포함한다. 2 shows how the second thread 200 processes data. In FIG. 2 , the second thread 200 includes a message queue 210 independent of the first thread 100 , an event loop 220 , and a call stack 230 .

메시지 큐(210)는 처리되어야 할 작업을 저장하는 모듈이다. 콜 스택(230)에는 작업을 수행하기 위한 함수의 호출 정보 등이 쌓인다. 콜 스택(230)은 가장 나중에 푸쉬(push)된 함수가 가장 먼저 호출(pop)되어 실행되는 LIFO(last in first out) 방식으로 동작한다. LIFO에 따라 콜 스택(230)에 쌓인 함수들이 모두 실행되면 콜 스택(230)은 비워지게 된다. 이벤트 루프(220)는 콜 스택(230)이 비워지면 메시지 큐(210)에서 대기중인 작업을 콜 스택(230)으로 이동시키는 기능을 수행한다.The message queue 210 is a module for storing tasks to be processed. In the call stack 230, call information of a function for performing an operation, etc. are accumulated. The call stack 230 operates in a last in first out (LIFO) method in which a function pushed last is called and executed first. When all the functions stacked in the call stack 230 are executed according to the LIFO, the call stack 230 is emptied. The event loop 220 performs a function of moving a job waiting in the message queue 210 to the call stack 230 when the call stack 230 is empty.

이상의 메시지 큐(210), 이벤트 루프(220) 그리고 콜 스택(230)의 기능을 바탕으로 제2 쓰레드(200)가 데이터를 처리하는 방법을 살펴본다. A method of processing data by the second thread 200 based on the functions of the message queue 210 , the event loop 220 , and the call stack 230 will be described.

제1 쓰레드(100)로부터 전달받은 데이터는 메시지 큐(210)에 저장된다. 메시지 큐(210)에 저장된 데이터는 콜 스택(230)이 비워지게 되면 이벤트 루프(220)에 의해 메시지 큐(210)에서 콜 스택(230)으로 이동한다. 이때 콜 스택(230)으로 이동하는 데이터는 메시지 큐(210)에 가장 먼저 저장된 데이터로 메시지 큐(210)에서 데이터는 FIFO(first in first out) 방식으로 인큐 및 디큐된다. 콜 스택(230)에서는 LIFO에 따라 콜 스택(230)에 쌓인 함수들을 실행하여 데이터를 처리한다. Data received from the first thread 100 is stored in the message queue 210 . Data stored in the message queue 210 moves from the message queue 210 to the call stack 230 by the event loop 220 when the call stack 230 becomes empty. At this time, data moving to the call stack 230 is data stored first in the message queue 210 , and data in the message queue 210 is enqueued and dequeued in a first in first out (FIFO) manner. The call stack 230 processes data by executing functions accumulated in the call stack 230 according to the LIFO.

제2 쓰레드(200)가 데이터를 처리하는 과정에서 메시지 큐(210)에는 제1 쓰레드(100)로부터 전달받은 데이터가 인큐되고 콜 스택(230)으로 이동을 위해 데이터가 디큐되는 작업이 반복하여 이루어진다. 메시지 큐(210)에 저장되어 있는 데이터의 개수는 제1 쓰레드(100)로부터 유입되는 데이터의 개수와 콜 스택(230)으로 유출되는 데이터의 개수에 따라 달라지게 된다. 이때, 제1 쓰레드(100)로부터 하나의 postMessage에 의해 전달되는 데이터를 하나의 데이터로 본다. 예를 들어 3 차례에 걸쳐 postMessage에 의해 제2 쓰레드(200)에 데이터가 전달된 경우, 전달된 데이터의 개수는 3개이다. In the process where the second thread 200 processes data, the message queue 210 enqueues the data received from the first thread 100 and dequeues the data to move to the call stack 230 repeatedly. . The number of data stored in the message queue 210 varies depending on the number of data flowing in from the first thread 100 and the number of data flowing out of the call stack 230 . In this case, data transmitted by one postMessage from the first thread 100 is regarded as one data. For example, when data is transferred to the second thread 200 by postMessage three times, the number of transferred data is three.

제1 쓰레드(100)로부터 유입되는 데이터의 개수가 콜 스택(230)으로 유출되는 데이터의 개수보다 많은 경우 메시지 큐(210)에 데이터가 쌓이게 된다. 이러한 상황이 지속되는 경우 병목현상으로 인해 메시지 큐(210)에 오버플로우가 발생할 수 있다. 이 경우 제2 쓰레드(200)의 스크립트 실행이 중지되는 상황이 발생할 수 있으며 심지어는 웹 브라우저 전체가 동작하지 않는 상황까지 발생할 수 있다.When the number of data flowing in from the first thread 100 is greater than the number of data flowing out to the call stack 230 , data is accumulated in the message queue 210 . If this situation continues, an overflow may occur in the message queue 210 due to a bottleneck. In this case, a situation in which the execution of the script of the second thread 200 is stopped may occur, or even a situation in which the entire web browser does not operate may occur.

이하 도 3 및 도 4에서는 메시지 큐(210)의 오버플로우를 방지하기 위한 방법으로 제2 쓰레드(200)가 메시지 큐(210)의 현재 상태를 확인하고 상태 정보를 제1 쓰레드(100)로 전달하는 방법에 대해 살펴본다.Hereinafter, in FIGS. 3 and 4 , as a method for preventing overflow of the message queue 210 , the second thread 200 checks the current state of the message queue 210 and transmits the state information to the first thread 100 . Let's see how to do it.

메시지 큐(210)에 오버플로우가 발생하는 것은 메시지 큐(210)에 데이터가 적체되기 시작하는 순간과 연관되어 있다. 즉, 메시지 큐(210)에 인큐되는 데이터의 개수가 디큐되는 데이터의 개수보다 많아지게 되면 병목현상이 발생할 수 있으며, 병목현상이 지속되어 데이터의 적재량이 한계치를 넘으면 오버플로우가 발생되게 된다. 따라서 제2 쓰레드(200)에서는 메시지 큐(210)에 인큐되는 데이터의 개수와 디큐되는 데이터의 개수를 비교하여 메시지 큐(210)의 현재 상태를 확인할 수 있다.The occurrence of an overflow in the message queue 210 is associated with the moment when data starts to accumulate in the message queue 210 . That is, when the number of data enqueued in the message queue 210 becomes greater than the number of data dequeued, a bottleneck may occur. Accordingly, the second thread 200 may check the current state of the message queue 210 by comparing the number of data enqueued in the message queue 210 with the number of data dequeued.

메시지 큐(210)에 인큐되는 데이터의 개수와 디큐되는 데이터의 개수를 비교하는 방법으로, 단위 시간동안 인큐 또는 디큐되는 데이터의 개수를 측정하는 방법이 있다. 또는 특정 개수의 데이터가 인큐되는 동안 디큐되는 데이터의 개수를 측정하여 비교할 수 있다. 즉, 제2 쓰레드(200)는 인큐되는 데이터의 개수와 디큐되는 데이터의 개수의 상대적인 비교가 가능하도록 각 데이터의 개수를 파악하여 메시지 큐(210)의 상태를 확인할 수 있다. As a method of comparing the number of data enqueued in the message queue 210 with the number of data dequeued, there is a method of measuring the number of data enqueued or dequeued for a unit time. Alternatively, while a specific number of data is enqueued, the number of dequeued data may be measured and compared. That is, the second thread 200 may check the state of the message queue 210 by identifying the number of data so that a relative comparison between the number of enqueued data and the number of dequeued data is possible.

제2 쓰레드(200)는 메시지 큐(210)의 상태를 확인하는 것에 따라 제1 쓰레드(100)로 메시지 큐(210)의 상태를 상태 데이터에 담아 전달할 수 있다. 이때, 제2 쓰레드(200)는 인큐되는 데이터의 개수가 더 많은 경우에만 상태 데이터를 제1 쓰레드(100)로 전송할 수도 있고, 또는 제1 쓰레드(100)로부터 데이터가 수신될 때마다 그에 대응하여 상태 데이터를 전송할 수 있다. The second thread 200 may transmit the state of the message queue 210 in state data to the first thread 100 according to checking the state of the message queue 210 . In this case, the second thread 200 may transmit the state data to the first thread 100 only when the number of enqueued data is larger, or whenever data is received from the first thread 100 , in response thereto State data can be transmitted.

상태 데이터에는 단위 시간동안 인큐되는 데이터의 개수와 디큐되는 데이터의 개수에 대한 정보가 포함될 수 있다. 또는 상태 데이터에 포함되는 정보는 특정 개수의 데이터가 인큐되는 동안 디큐되는 데이터의 개수를 포함할 수 있다. 또는 제2 쓰레드(200)는 인큐되는 데이터의 개수와 디큐되는 데이터의 개수를 비교하여 오버플로우의 위험정도를 단계로 측정하여, 측정한 단계를 상태 데이터에 담아 제1 쓰레드(100)로 전송할 수 있다. 예를 들면, 제2 쓰레드(200)는 인큐되는 데이터의 개수가 과도한 경우에는 '위험단계'를, 인큐되는 데이터의 개수가 적은 경우에는 '양호단계'를 상태 데이터에 담아 제1 쓰레드(100)로 전송할 수 있다. The state data may include information on the number of enqueued data and the number of dequeued data for a unit time. Alternatively, the information included in the state data may include the number of data dequeued while a specific number of data is enqueued. Alternatively, the second thread 200 compares the number of enqueued data with the number of dequeued data to measure the degree of risk of overflow in stages, and transmits the measured stage in state data to the first thread 100 . there is. For example, when the number of enqueued data is excessive, the second thread 200 puts a 'dangerous stage' in the state data, and when the number of enqueued data is small, the 'good stage' is stored in the state data of the first thread 100 can be sent to

도 3을 통해 단위 시간동안 인큐되는 데이터(211)의 개수와 디큐되는 데이터(212)의 개수를 통해 메시지 큐(210)의 상태를 파악하는 방법을 보다 자세히 살펴본다. 도 3에서 단위 시간동안 인큐되는 데이터(211)의 개수는 2개이고 디큐되는 데이터(212)의 개수는 1개이다. 이는 인큐되는 데이터(211)의 개수가 디큐되는 데이터(212)의 개수보다 많은 경우로 메시지 큐(210)에 오버플로우가 발생할 위험이 있는 상태에 해당한다. 따라서 제2 쓰레드(200)는 인큐되는 데이터(211) 및 디큐되는 데이터(212)의 개수 정보를 포함하는 상태 데이터를 제1 쓰레드(100)로 보낸다. 또는 제2 쓰레드(200)는 '위험단계'라는 정보를 포함하는 상태 데이터를 보낸다.A method of determining the state of the message queue 210 through the number of enqueued data 211 and dequeued data 212 for a unit time will be described in detail with reference to FIG. 3 . In FIG. 3 , the number of data 211 to be enqueued for a unit time is two and the number of data 212 to be dequeued is one. This is a case in which the number of enqueued data 211 is greater than the number of dequeued data 212 and corresponds to a state in which there is a risk of overflow in the message queue 210 . Accordingly, the second thread 200 transmits state data including information on the number of enqueued data 211 and dequeued data 212 to the first thread 100 . Alternatively, the second thread 200 transmits state data including information of a 'dangerous stage'.

도 4는 메시지 큐(210)에 저장된 데이터(213)를 나타낸다. 도 3에서 인큐되는 데이터(211)와 디큐되는 데이터(212)의 개수를 비교하여 메시지 큐(210)의 상태를 확인하는 실시예를 살펴보았다면, 도 4에서는 메시지 큐(210)에 저장된 데이터(213)의 개수로 메시지 큐(210)의 상태를 확인하는 실시예를 살펴본다. 4 shows data 213 stored in a message queue 210 . Referring to an embodiment in which the state of the message queue 210 is checked by comparing the number of enqueued data 211 and dequeued data 212 in FIG. 3 , in FIG. 4 , data stored in the message queue 210 ( An embodiment of checking the status of the message queue 210 by the number of 213) will be described.

메시지 큐(210)에 한계치를 넘는 개수의 메시지가 저장되기 시작하면 메시지 큐(210)에 오버플로우가 발생할 수 있다. 따라서 제2 쓰레드(200)는 특정 시점에 메시지 큐(210)에 저장되어 있는 데이터의 개수를 파악하는 것을 통해 메시지 큐(210)의 상태를 확인할 수 있다. When the message queue 210 starts to store a number of messages exceeding the limit, an overflow may occur in the message queue 210 . Accordingly, the second thread 200 may check the state of the message queue 210 by determining the number of data stored in the message queue 210 at a specific time.

제2 쓰레드(200)가 특정 시점에 메시지 큐(210)에 저장되어 있는 데이터의 개수를 파악하는 방법은, 특정 시점에 메시지 큐(210)에 저장되어 있는 데이터의 개수를 직접적으로 카운트하여 파악하는 방법일 수 있고 또는 특정 시점까지 인큐된 데이터의 개수와 디큐된 데이터의 개수의 차를 통해 파악하는 방법일 수 있다.The method for the second thread 200 to determine the number of data stored in the message queue 210 at a specific point in time is to directly count and determine the number of data stored in the message queue 210 at a specific point in time. It may be a method or a method of identifying through a difference between the number of enqueued data and the number of dequeued data up to a specific time point.

제2 쓰레드(200)가 메시지 큐(210)에 저장된 데이터 개수를 파악하는 특정 시점은 제1 쓰레드(100)로부터 데이터가 수신될 때 일 수도 있고, 메시지 큐(210)에서 콜 스택(230)으로 데이터가 디큐될 때 일 수도 있으며, 또는 특정 시간 간격으로 반복되는 시점일 수 있다. The specific point in time at which the second thread 200 determines the number of data stored in the message queue 210 may be when data is received from the first thread 100 , or from the message queue 210 to the call stack 230 . It may be when data is dequeued, or it may be a time point that is repeated at a specific time interval.

제2 쓰레드(200)는 메시지 큐(210)의 상태를 확인하는 것에 따라 파악된 데이터 개수에 관한 정보를 담은 상태 메시지를 제1 쓰레드(100)로 전달할 수 있다. 이때, 제2 쓰레드(200)는 메시지 큐(210)에 저장된 데이터의 개수가 일정치를 초과하는 경우에만 상태 데이터를 제1 쓰레드(100)로 전송할 수도 있고, 또는 제1 쓰레드(100)로부터 데이터가 수신될 때마다 상태 데이터를 전송할 수도 있다. 여기서 일정치는 메시지 큐(210)의 오버플로우를 방지하도록 정해지는 수치로 사용자에 의해 정해진 값이거나 메시지 큐(210)에 오버플로우가 일어나는 경우에 대한 학습을 통해 정해진 값일 수 있다.The second thread 200 may transmit a status message including information on the number of identified data according to the checking of the status of the message queue 210 to the first thread 100 . In this case, the second thread 200 may transmit the state data to the first thread 100 only when the number of data stored in the message queue 210 exceeds a predetermined value, or data from the first thread 100 The state data may be transmitted whenever is received. Here, the constant value is a number determined to prevent overflow of the message queue 210 , and may be a value determined by a user or a value determined through learning when an overflow occurs in the message queue 210 .

상태 데이터에는 메시지 큐(210)에 저장된 데이터의 개수에 대한 정보가 포함될 수 있다. 또는 제2 쓰레드(200)는 메시지 큐(210)에 저장된 데이터의 개수와 일정치를 비교하여 오버플로우의 위험정도를 단계로 측정하여 측정한 단계를 상태 데이터에 담아 제1 쓰레드(100)로 전송할 수 있다. 예를 들면, 제2 쓰레드(200)는 저장된 데이터의 개수가 일정치에 매우 근접하거나 초과한 경우에는 '위험단계'를, 저장된 데이터의 개수가 일정치를 밑도는 경우에는 '양호단계'를 상태 데이터에 담아 제1 쓰레드(100)로 전송할 수 있다. The state data may include information on the number of data stored in the message queue 210 . Alternatively, the second thread 200 compares the number of data stored in the message queue 210 with a constant value, measures the degree of risk of overflow in stages, and transmits the measured stage in state data to the first thread 100 . can For example, the second thread 200 sets a 'dangerous stage' when the number of stored data very close to or exceeds a predetermined value, and a 'good stage' when the number of stored data falls below a predetermined value. It can be stored in and transmitted to the first thread 100 .

도 4를 통해 특정 시점에 메시지 큐(210)에 저장되어 있는 데이터의 개수를 통해 메시지 큐(210)의 상태를 파악하는 방법을 보다 자세히 살펴본다. 도 4에는 메시지 큐(210)에 저장된 데이터(213)가 3개 이다. 일정치를 7이라 하면, 저장된 데이터(213)의 개수는 일정치를 밑도는 수치이므로 제2 쓰레드(200)는 제1 쓰레드(100)로 상태 데이터를 보내지 않거나, 저장된 데이터(213)의 개수 또는'양호단계'라는 정보를 담은 상태 데이터를 보낼 수 있다.A method of determining the state of the message queue 210 through the number of data stored in the message queue 210 at a specific point in time will be described in more detail with reference to FIG. 4 . In FIG. 4 , there are three pieces of data 213 stored in the message queue 210 . If the constant value is 7, the number of stored data 213 is less than the predetermined value, so the second thread 200 does not send the state data to the first thread 100, or the number of stored data 213 or ' It is possible to send status data containing the information 'good level'.

이상 도 3 및 도 4를 통해 제2 쓰레드(200)가 메시지 큐(210)의 상태를 확인하는 방법과 확인한 상태를 제1 쓰레드(100)로 전달하는 방법에 대해 살펴보았다. 이하 도 5 및 도 6에서는 메시지 큐(210)의 오버플로우를 방지하기 위해 제1 쓰레드(100)에서 데이터 개수를 조절하고, 개수가 조절된 데이터를 전달하는 방법을 살펴본다.3 and 4, a method for the second thread 200 to check the status of the message queue 210 and a method for transferring the checked status to the first thread 100 have been described. Hereinafter, a method of controlling the number of data in the first thread 100 to prevent overflow of the message queue 210 and transmitting the adjusted data will be described in FIGS. 5 and 6 .

도 5는 종래의 방식으로 제1 쓰레드(100)에서 제2 쓰레드(200)로 데이터를 전달하는 방법을 나타낸다. 도 5에서 데이터1, 데이터2, 및 데이터3은 처리하고자 하는 데이터들을 나타낸다. 도 1에서 살펴보았듯이 postMessage 방법은 단일 변수를 취급하기 때문에 상기 데이터들은 개별적으로 postMessage를 통해 제2 쓰레드(200)로 전달되어야 한다. 따라서 postMessage를 통해 전달되어 메시지 큐(210)에 인큐되는 데이터의 개수는 3개가 된다.5 shows a method of transferring data from the first thread 100 to the second thread 200 in a conventional manner. In FIG. 5, data 1, data 2, and data 3 indicate data to be processed. 1, since the postMessage method handles a single variable, the data must be individually transmitted to the second thread 200 through postMessage. Therefore, the number of data delivered through postMessage and enqueued in the message queue 210 is three.

도 6는 본 발명의 실시예인, 제1 쓰레드(100)에서 중간 데이터를 생성하여 제2 쓰레드(200)로 전달하는 방법을 나타낸다. 도 6의 실시예에서 제1 쓰레드(100)는 도 5와 마찬가지로 데이터1, 데이터2, 및 데이터3를 제2 쓰레드(200)로 전달하되 메시지 큐(210)에 인큐되는 데이터의 개수를 줄이고자 한다. 이를 위해 제1 쓰레드(100)는 데이터1, 데이터2, 그리고 데이터 3을 병합하여 중간 데이터를 생성한다. 제1 쓰레드(100)는 각각의 데이터 대신 중간 데이터를 postMessage를 통해 제2 쓰레드(200)로 전달하면 메시지 큐(210)에는 1개의 데이터가 인큐되게 된다. 6 illustrates a method of generating intermediate data in the first thread 100 and transmitting the intermediate data to the second thread 200 according to an embodiment of the present invention. In the embodiment of FIG. 6 , the first thread 100 transmits data 1 , data 2 , and data 3 to the second thread 200 as in FIG. 5 , but in order to reduce the number of data enqueued in the message queue 210 . do. To this end, the first thread 100 generates intermediate data by merging data1, data2, and data3. When the first thread 100 transmits intermediate data instead of each data to the second thread 200 through postMessage, one piece of data is enqueued in the message queue 210 .

도 6의 실시예에서 3개의 데이터들을 병합하여 중간 데이터를 생성하였으나 이는 설명의 편의를 위해 설정된 개수일 뿐 병합되는 데이터의 개수를 3개로 한정하는 것은 아니다. 즉, 중간 데이터는 적어도 2개 이상의 데이터를 병합하여 생성될 수 있다. 또한 제1 쓰레드(100)에서 중간 데이터를 생성하는 데이터의 개수가 고정되어 있는 것은 아니다. 제1 쓰레드(100)는 프로세스를 진행하면서 필요에 따라 데이터의 개수를 변경하여 중간 데이터를 생성할 수 있다. In the embodiment of FIG. 6 , intermediate data is generated by merging three pieces of data, but this is only a set number for convenience of description and does not limit the number of data to be merged to three. That is, the intermediate data may be generated by merging at least two pieces of data. Also, the number of data generating intermediate data in the first thread 100 is not fixed. The first thread 100 may generate intermediate data by changing the number of data as needed while performing a process.

이상 도 3 및 도 4에서는 제2 쓰레드(200)가 메시지 큐(210)의 상태를 확인하고 제1 쓰레드(100)로 상태 데이터를 전달하는 방법을, 도 5 및 도 6에서는 제1 쓰레드(100)에서 중간 데이터를 생성하는 방법을 살펴보았다. 이상의 내용을 바탕으로 이하 도 7 내지 도 9에서는 제1 쓰레드(100)가 메시지 큐(210)의 상태에 따라 제2 쓰레드(200)로 데이터 개수를 조절하여 전달하는 방법에 대해 살펴본다.3 and 4, the second thread 200 checks the status of the message queue 210 and transmits the status data to the first thread 100. In FIGS. 5 and 6, the first thread 100 ), we looked at how to generate intermediate data. Based on the above, a method in which the first thread 100 adjusts the number of data and transmits the data to the second thread 200 according to the state of the message queue 210 will be described in FIGS. 7 to 9 .

도 7은 제1 쓰레드(100)가 메시지 큐(210)의 상태에 따라 제2 쓰레드(200)로 데이터 개수를 조절하여 전달하는 방법에 대한 일 실시예를 나타낸다. 7 shows an embodiment of a method in which the first thread 100 adjusts the number of data and transmits the data to the second thread 200 according to the state of the message queue 210 .

제1 쓰레드(100)는 제2 쓰레드(200)로 처리하고자 하는 각각의 데이터들을 개별적으로 제2 쓰레드(200)로 전달한다. 즉, 중간 데이터의 생성 없이 도 5에서 살펴보았던 종래의 방식을 이용하여 데이터들을 제2 쓰레드(200)로 전달한다.The first thread 100 individually transmits data to be processed by the second thread 200 to the second thread 200 . That is, data is transferred to the second thread 200 using the conventional method illustrated in FIG. 5 without generating intermediate data.

제2 쓰레드(200)는 메시지 큐(210)에 유입되는 데이터의 개수가 유출되는 데이터의 개수보다 많은 경우 또는 메시지 큐(210)에 저장된 데이터의 개수가 일정치를 초과하는 경우에 상태 메시지를 제1 쓰레드(100)로 전달한다.The second thread 200 issues a status message when the number of data flowing into the message queue 210 is greater than the number of data flowing out or when the number of data stored in the message queue 210 exceeds a certain value. It is transmitted to the 1st thread (100).

제1 쓰레드(100)는 제2 쓰레드(200)로부터 상태 데이터를 수신하였는지 여부를 판단한다. 상태 데이터를 수신하지 않은 경우 제1 쓰레드(100)는 처리하고자 하는 각각의 데이터들을 개별적으로 제2 쓰레드(200)로 전달한다. The first thread 100 determines whether state data has been received from the second thread 200 . When the state data is not received, the first thread 100 individually transmits each data to be processed to the second thread 200 .

반면에 상태 데이터를 수신한 경우 제1 쓰레드(100)는 메시지 큐(210)의 오버플로우를 방지하기 위해, 데이터를 개별적으로 전달하는 대신에 도 6에서 살펴보았던 방식으로 복수의 데이터들을 병합하여 중간 데이터를 생성하고 상기 중간 데이터를 제2 쓰레드(200)로 전달한다.On the other hand, when receiving the status data, the first thread 100 merges a plurality of data in the manner shown in FIG. 6 instead of individually delivering the data to prevent overflow of the message queue 210 to Data is generated and the intermediate data is transmitted to the second thread 200 .

도 8은 제1 쓰레드(100)가 메시지 큐(210)의 상태에 따라 제2 쓰레드(200)로 데이터 개수를 조절하여 전달하는 방법에 대한 다른 실시예를 나타낸다. 8 shows another embodiment of a method in which the first thread 100 adjusts the number of data and transmits the data to the second thread 200 according to the state of the message queue 210 .

제1 쓰레드(100)는 중간 데이터의 생성 없이 각각의 데이터를 개별적으로 제2 쓰레드(200)로 전달한다. The first thread 100 individually transmits each data to the second thread 200 without generating intermediate data.

제2 쓰레드(200)는 메시지 큐(210)에 유입되는 데이터의 개수가 유출되는 데이터의 개수보다 많은 경우 또는 메시지 큐(210)에 저장된 데이터의 개수가 일정치를 초과하는 경우에 상태 메시지를 제1 쓰레드(100)로 전달한다.The second thread 200 issues a status message when the number of data flowing into the message queue 210 is greater than the number of data flowing out or when the number of data stored in the message queue 210 exceeds a certain value. It is transmitted to the 1st thread (100).

제1 쓰레드(100)는 제2 쓰레드(200)로부터 상태 데이터를 수신하였는지 여부를 판단한다. 상태 데이터를 수신하지 않은 경우 제1 쓰레드(100)는 처리하고자 하는 각각의 데이터들을 개별적으로 제2 쓰레드(200)로 전달한다. The first thread 100 determines whether state data has been received from the second thread 200 . When the state data is not received, the first thread 100 individually transmits each data to be processed to the second thread 200 .

반면에 상태 데이터를 수신한 경우 제1 쓰레드(100)는 상태 데이터를 바탕으로 메시지 큐(210)에 오버플로우의 발생이 예측되는지 여부를 판단한다. 오버플로우 발생이 예측되지 않으면 제1 쓰레드(100)는 처리하고자 하는 각각의 데이터들을 개별적으로 제2 쓰레드(200)로 전달한다. 오버플로우 발생이 예측되면 제1 쓰레드(100)는 개별적으로 전달하고자 하였던 복수의 데이터들을 병합하여 중간 데이터를 생성하고 중간 데이터를 제2 쓰레드(200)로 전달한다. On the other hand, when the state data is received, the first thread 100 determines whether the occurrence of an overflow in the message queue 210 is predicted based on the state data. If overflow is not predicted, the first thread 100 individually transfers each data to be processed to the second thread 200 . When overflow is predicted, the first thread 100 generates intermediate data by merging a plurality of data to be individually transmitted, and transmits the intermediate data to the second thread 200 .

오버플로우의 발생이 예측되는지 여부는 상태 데이터에 담긴 정보를 이용하여 판단할 수 있다. 현재 상태 데이터에 담긴 정보가 메시지 큐(210)에 저장된 데이터의 개수인 경우 상기 개수가 일정치를 넘는지를 판단하여 오버플로우의 발생 여부를 예측할 수 있다. 또는 과거 상태 데이터에 담긴 정보를 토대로 현재 상태 데이터의 정보에 담긴 메시지 큐(210)에 저장된 데이터의 개수를 상대적으로 비교하여 오버플로우의 발생 여부를 예측할 수 있다. 즉, 상대적으로 비교하는 방식은, 이전에 받은 상태 데이터와 현재 받은 상태 데이터를 통해 메시지 큐(210)의 상태의 변화 정도에 따라 오버플로우의 발생 여부를 예측한다. Whether the occurrence of overflow is predicted may be determined using information contained in the state data. When the information contained in the current state data is the number of data stored in the message queue 210, it is possible to predict whether an overflow occurs by determining whether the number exceeds a predetermined value. Alternatively, the occurrence of overflow may be predicted by relatively comparing the number of data stored in the message queue 210 contained in the information of the current state data based on the information contained in the past state data. That is, the relatively comparison method predicts whether overflow occurs according to the degree of change in the state of the message queue 210 through the previously received state data and the currently received state data.

도 9는 제1 쓰레드(100)가 메시지 큐(210)의 상태에 따라 제2 쓰레드(200)로 데이터 개수를 조절하여 전달하는 방법에 대한 또 다른 실시예를 나타낸다. 9 shows another embodiment of a method in which the first thread 100 adjusts the number of data and transmits the data to the second thread 200 according to the state of the message queue 210 .

도 9의 실시예에서는 도 5 및 도 6의 실시예와 달리 제1 쓰레드(100)가 처음부터 제2 쓰레드(200)로 중간 데이터를 생성하여 전달한다. 이는 과거의 프로세스들로부터 메시지 큐(210)의 오버플로우를 방지하기 위한 중간 데이터의 전달 요건을 경험적으로 터득하여 활용하는 경우이다. 이전에 수행했던 프로세스와 동일 또는 유사한 프로세스를 수행하고자 하는 경우, 제1 쓰레드(100)는 이전 프로세스에서 중간 데이터를 사용하는데 사용된 데이터의 개수를 참조하여 처음부터 제2 쓰레드(200)로 중간 데이터를 생성하여 전달할 수 있다.In the embodiment of FIG. 9 , unlike the embodiments of FIGS. 5 and 6 , the first thread 100 generates and transmits intermediate data to the second thread 200 from the beginning. This is a case where the intermediate data transfer requirements for preventing the overflow of the message queue 210 from past processes are learned and utilized empirically. When it is desired to perform the same or similar process as the previously performed process, the first thread 100 transfers the intermediate data to the second thread 200 from the beginning with reference to the number of data used to use the intermediate data in the previous process. can be created and delivered.

제2 쓰레드(200)는 메시지 큐(210)에 유입되는 데이터의 개수가 유출되는 데이터의 개수보다 많은 경우 또는 메시지 큐(210)에 저장된 데이터의 개수가 일정치를 초과하는 경우에 상태 메시지를 제1 쓰레드(100)로 전달한다.The second thread 200 issues a status message when the number of data flowing into the message queue 210 is greater than the number of data flowing out or when the number of data stored in the message queue 210 exceeds a certain value. It is transmitted to the 1st thread (100).

제1 쓰레드(100)는 제2 쓰레드(200)로부터 상태 데이터를 수신하였는지 여부를 판단한다. 제1 쓰레드(100)는 상태 데이터를 수신하지 않은 경우 이전 단계와 동일한 방식으로 중간 데이터를 생성하여 제2 쓰레드(200)로 전달한다. The first thread 100 determines whether state data has been received from the second thread 200 . When the first thread 100 does not receive the state data, it generates intermediate data in the same manner as in the previous step and transmits it to the second thread 200 .

반면에 상태 데이터를 수신한 경우에는 이전 단계에서 중간 데이터를 생성하는데 사용된 데이터의 개수보다 더 많은 개수의 데이터로 새로운 중간 데이터를 생성하여 제2 쓰레드(200)로 전달한다.On the other hand, when the state data is received, new intermediate data is generated with a larger number of data than the number of data used to generate the intermediate data in the previous step and transferred to the second thread 200 .

이상 도 3 내지 도 9에서 살펴본 방식을 통해 제1 쓰레드(100)에서 제2 쓰레드(200)로 데이터를 전달하면 메시지 큐(210)에 오버플로우가 발생하는 것을 방지할 수 있다. 이하 도 10 내지 도 14에서는 이상의 방법을 영상 데이터의 처리에 적용한 경우를 살펴본다.When data is transmitted from the first thread 100 to the second thread 200 through the method described above with reference to FIGS. 3 to 9 , an overflow in the message queue 210 can be prevented. Hereinafter, a case in which the above method is applied to image data processing will be described with reference to FIGS. 10 to 14 .

도 10은 멀티 쓰레드로 영상 데이터를 처리하는 장치를 나타낸다. 도 10의 영상처리장치는 웹 브라우저 상에서 제1 쓰레드(100) 및 제2 쓰레드(200)를 이용하여 영상 데이터를 처리한다. 상기 영상처리장치에서 처리하고자 하는 영상 데이터는 RTP 프로토콜을 이용하여 수신된, 패킷화된 영상 데이터이다. 상기 영상처리장치에서 제1 쓰레드(100)는 웹소켓 클라이언트(101), RTP 클라이언트(102), 및 디코더 모듈(103)을 포함하고 제2 쓰레드(200)는 디패킷화 모듈(201)을 포함한다.10 shows an apparatus for processing image data in a multi-threaded manner. The image processing apparatus of FIG. 10 processes image data using a first thread 100 and a second thread 200 on a web browser. The image data to be processed by the image processing apparatus is packetized image data received using the RTP protocol. In the image processing apparatus, the first thread 100 includes a websocket client 101 , an RTP client 102 , and a decoder module 103 , and the second thread 200 includes a depacketization module 201 . do.

상기 영상처리장치에서 영상 데이터를 처리하는 과정을 살펴보면, 먼저 제1 쓰레드(100)가 서버에서 네트워크를 통해 전송된 영상 데이터를 수신한다. 제1 쓰레드(100)에서 영상 데이터의 수신에 이용되는 모듈은 웹소켓 클라이언트(101)와 RTP 클라이언트(102)이다. Looking at the process of processing image data in the image processing apparatus, first, the first thread 100 receives image data transmitted from a server through a network. Modules used to receive image data in the first thread 100 are the WebSocket client 101 and the RTP client 102 .

웹소켓 클라이언트(101)는 서버와 웹소켓 연결을 수립하는 모듈이다. 웹소켓 클라이언트(101)는 서버와 핸드쉐이크를 거쳐 데이터를 주고 받는다. 웹소켓 클라이언트(101)와 서버 간에 웹소켓 연결이 수립되면 그 이후에는 양자간에 지속적인 데이터의 송수신이 가능해진다.The websocket client 101 is a module that establishes a websocket connection with the server. The WebSocket client 101 exchanges data with the server through a handshake. When a WebSocket connection is established between the WebSocket client 101 and the server, continuous data transmission/reception between the two is possible thereafter.

RTP 클라이언트(102)는 서버와 RTP 통신을 지원하는 기능을 수행한다. RTP 클라이언트(102)는 HTTP를 이용하는 웹 브라우저에서도 안정적으로 RTP 프로토콜로 전송된 데이터를 수신할 수 있는 기능을 제공한다.The RTP client 102 performs a function of supporting RTP communication with the server. The RTP client 102 provides a function capable of receiving data transmitted through the RTP protocol stably even in a web browser using HTTP.

웹소켓 클라이언트(101)와 RTP 클라이언트(102)에 의해 수신된 영상 데이터는 패킷화된 데이터로, RTP 데이터라 칭한다. 제1 쓰레드(100)는 디패킷화를 위해 RTP 데이터를 제2 쓰레드(200)로 전달한다. The image data received by the WebSocket client 101 and the RTP client 102 is packetized data, and is referred to as RTP data. The first thread 100 transfers RTP data to the second thread 200 for depacketization.

제2 쓰레드(200)의 디패킷화 모듈(201)은 전달받은 RTP 데이터를 디패킷화하는 작업을 수행한다. 디패킷화 된 RTP 데이터를 프레임 데이터라 칭한다. 제2 쓰레드(200)는 RTP 데이터들로부터 복원된 프레임 데이터를 제1 쓰레드(100)로 전달한다.The depacketizing module 201 of the second thread 200 depacketizes the received RTP data. The depacketized RTP data is called frame data. The second thread 200 transfers frame data restored from RTP data to the first thread 100 .

제1 쓰레드(100)의 디코더 모듈(103)에서는 제2 쓰레드(200)로부터 전달받은 프레임 데이터를 디코딩 한다. 이때 디코더 모듈(103)은 자바스크립트로 구현된 스크립트일 수 있고 또는 웹 브라우저에 임베드 된 디코더일 수 있다. 또한 디코더 모듈(103)에서 디코딩은 프레임 단위로 이루어지거나 또는 복수의 프레임으로 이루어진 컨테이너 단위로 이루어질 수 있다.The decoder module 103 of the first thread 100 decodes the frame data received from the second thread 200 . In this case, the decoder module 103 may be a script implemented in JavaScript or a decoder embedded in a web browser. Also, decoding in the decoder module 103 may be performed in units of frames or in units of containers composed of a plurality of frames.

이상의 과정을 통해 영상처리장치는 웹 브라우저 상에서 멀티 쓰레드로 영상 데이터를 처리한다. 그런데 상기 과정을 도 5의 종래의 방식을 이용하여 수행할 경우 RTP 프로토콜의 특성상 메시지 큐(210)에 오버플로우가 발생할 수 있다. 이에 대하여 자세히 살펴보기 위해 도 11을 참조한다. Through the above process, the image processing apparatus processes image data in multi-threads on the web browser. However, when the above process is performed using the conventional method of FIG. 5 , an overflow may occur in the message queue 210 due to the characteristics of the RTP protocol. For a detailed look at this, refer to FIG. 11 .

도 11은 RTP 데이터와 프레임 데이터를 나타낸다. 11 shows RTP data and frame data.

일반적으로 서버에서는 패킷화된 영상 데이터를 전송한다. 패킷화란 영상 데이터를 네트워크를 통해 전송하는 것이 용이하도록 적당한 길이로 분할하거나 또는 영상 데이터가 짧은 경우 적당한 길이로 일괄하여 그 각각에 수신되어야 할 주소 등의 제어정보를 부여하는 것을 뜻한다. RTP 데이터는 RTP 프로토콜에 따라 패킷화된 영상 데이터이며 RTP 헤더와 RTP 페이로드로 이루어진다. RTP 헤더에는 RTP 데이터의 전송 순서를 나타내는 시퀀스 번호, 영상의 동기화를 위한 시간 스탬프 등이 기록되고 RTP 페이로드에는 분할된 영상 데이터가 탑재된다. In general, the server transmits packetized image data. Packetization refers to dividing video data into appropriate lengths to facilitate transmission over a network, or assigning control information, such as addresses to be received, to each of video data by grouping them into appropriate lengths in case of short video data. RTP data is video data packetized according to the RTP protocol and consists of an RTP header and an RTP payload. A sequence number indicating the transmission order of RTP data, a time stamp for video synchronization, etc. are recorded in the RTP header, and segmented video data is loaded in the RTP payload.

영상 데이터의 재생을 위해서는 RTP 데이터를 디패킷화 하여야 한다. 디패킷화란 패킷화와 반대되는 개념으로 분할된 영상 데이터들을 축적하였다가 조립하여 완전한 하나의 프레임을 생성하는 것을 뜻한다. 복수의 RTP 데이터들에 대하여, 헤더 정보를 이용하여 시퀀스에 맞게 페이로드들을 조립하면 디패킷화 된 프레임 데이터를 생성할 수 있다.In order to reproduce video data, RTP data must be depacketized. Depacketization is a concept opposite to packetization and refers to accumulating and assembling segmented image data to create a complete frame. For a plurality of RTP data, if payloads are assembled according to a sequence using header information, depacketized frame data can be generated.

RTP 프로토콜을 기반으로 한 패킷의 크기는 제한적이므로 영상 데이터는 소정의 크기(예: 512Byte)로 분할되어 전송되게 된다. 따라서 하나의 프레임 데이터를 복원하기 위해 다수의 RTP 데이터가 사용될 수 있는데 이 경우, 제1 쓰레드(100)에서 제2 쓰레드(200)로 과도한 RTP 데이터가 전달되어 메시지 큐(210)에 오버플로우가 발생할 수 있다. Since the size of the packet based on the RTP protocol is limited, the image data is divided into a predetermined size (eg, 512 bytes) and transmitted. Therefore, a plurality of RTP data may be used to restore one frame data. In this case, excessive RTP data is transferred from the first thread 100 to the second thread 200 and an overflow may occur in the message queue 210 . can

이하 도 12 내지 도 14에서는 오버플로우의 발생 없이 웹 브라우저 상에서 멀티 쓰레드로 영상 데이터를 처리하는 방법을 살펴본다. Hereinafter, a method of processing image data in a multi-thread in a web browser without overflow will be described in FIGS. 12 to 14 .

도 12는 본 발명의 실시예인, 영상처리장치를 나타낸다. 도 10과 비교하였을 때 도 12에는 제1 쓰레드(100)에서 제2 쓰레드(200)로 RTP 데이터가 아닌 RTPInt 데이터가 전달되고 있다. 도 12의 영상처리장치에 대한 설명에 앞서 RTPInt 데이터에 대한 설명을 하기 위해 도 13 및 도 14를 참조한다.12 shows an image processing apparatus according to an embodiment of the present invention. Compared to FIG. 10 , in FIG. 12 , RTPInt data, not RTP data, is transmitted from the first thread 100 to the second thread 200 . Prior to the description of the image processing apparatus of FIG. 12 , reference will be made to FIGS. 13 and 14 for description of RTPInt data.

도 13은 RTP 데이터, RTPInt 데이터, 및 프레임 데이터를 나타낸다. RTP 데이터와 프레임 데이터는 도 10에서 설명하였으므로 중복되는 설명은 생략한다.13 shows RTP data, RTPInt data, and frame data. Since the RTP data and the frame data have been described with reference to FIG. 10, overlapping descriptions will be omitted.

본 발명에서는 제1 쓰레드(100)에서 제2 쓰레드(200)로 과도한 개수의 데이터가 전달되는 것을 방지하기 위해 중간 데이터를 이용하는데, 복수의 RTP 데이터들을 조립하여 생성한 중간 데이터가 RTPInt 데이터 이다. In the present invention, intermediate data is used to prevent an excessive number of data from being transmitted from the first thread 100 to the second thread 200, and the intermediate data generated by assembling a plurality of RTP data is RTPInt data.

RTPInt 데이터를 생성하기 위해 복수의 RTP 데이터들의 헤더 정보가 사용된다. 제1 쓰레드(100)는 RTP 데이터들의 헤더 정보를 이용하여 시퀀스에 맞게 RTP 데이터들을 병합하여 RTPInt 데이터를 생성할 수 있다.Header information of a plurality of RTP data is used to generate RTPInt data. The first thread 100 may generate RTPInt data by merging RTP data according to a sequence using header information of the RTP data.

도 14는 RTP 데이터와 RTPInt 데이터가 인큐된 메시지 큐(210a, 210b)를 나타낸다. 14 shows message queues 210a and 210b in which RTP data and RTPInt data are enqueued.

프레임 데이터를 만드는데 3개의 RTP 데이터가 필요하다고 하였을 때, 제1 쓰레드(100)로부터 RTP 데이터가 개별적으로 전달되는 경우에는 프레임 데이터를 만들기 위해 메시지 큐(210a)에 3개의 데이터가 인큐되어야 한다. 반면, 제1 쓰레드(100)에서 상기 3개의 RTP 데이터를 병합하여 하나의 RTPInt 데이터를 생성한 경우, 프레임 데이터를 만들기 위해 메시지 큐(210b)에는 1개의 데이터만 인큐되게 된다. When it is said that three RTP data are required to create frame data, when RTP data is individually transmitted from the first thread 100, three data must be enqueued in the message queue 210a to create frame data. On the other hand, when the first thread 100 merges the three RTP data to generate one RTPInt data, only one data is enqueued in the message queue 210b to create frame data.

즉, 중간 데이터를 사용하여 영상 데이터를 처리하면 더 적은 개수의 데이터를 메시지 큐(210)에 인큐시키면서 제2 쓰레드(200)에서 동일한 작업을 수행하는 것이 가능하다. 따라서 본 발명에 따르면 RTP 프로토콜에 따라 소정의 크기로 분할되어 전송된 영상 데이터를 메시지 큐(210)의 오버플로우 발생 없이 제2 쓰레드(200)에서 디패킷화 할 수 있다. That is, if the image data is processed using the intermediate data, it is possible to perform the same operation in the second thread 200 while enqueuing a smaller number of data in the message queue 210 . Therefore, according to the present invention, image data divided into a predetermined size according to the RTP protocol and transmitted can be depacketized in the second thread 200 without overflow of the message queue 210 .

다시 도 12로 돌아와 영상처리장치의 작동 과정을 설명한다. 도 10의 영상처리장치는 제1 쓰레드(100)가 RTP 데이터를 제2 쓰레드(200)로 전달하였다면, 도 12의 영상처리장치에서 제1 쓰레드(100)는 메시지 큐(210)의 상태에 따라 RTP 데이터 또는 RTP 데이터들을 병합한 중간 데이터인 RTPInt 데이터를 제2 쓰레드(200)로 전달한다. 제2 쓰레드(200)는 RTP 데이터 또는 RTPInt 데이터를 디패킷화하여 프레임 데이터를 생성하고 제1 쓰레드(100)로 전달한다. 제1 쓰레드(100)는 제2 쓰레드(200)로부터 전달받은 프레임 데이터를 디코더 모듈(103)에서 디코딩하여 복원한다. Returning to FIG. 12 again, an operation process of the image processing apparatus will be described. In the image processing apparatus of FIG. 10 , if the first thread 100 transmits RTP data to the second thread 200 , in the image processing apparatus of FIG. 12 , the first thread 100 transmits the message queue 210 according to the state of the message queue 210 . RTP data or RTPInt data, which is intermediate data obtained by merging RTP data, is transferred to the second thread 200 . The second thread 200 depacketizes RTP data or RTPInt data to generate frame data and transmits it to the first thread 100 . The first thread 100 decodes the frame data received from the second thread 200 in the decoder module 103 to restore it.

도 12의 실시예에 따르면 메시지 큐(210)의 오버플로우 발생 없이 안정적으로 웹 브라우저 상에서 멀티 쓰레드로 영상 데이터를 처리하는 것이 가능하다. 따라서 본 발명은 라이브 스트리밍 등 실시간성이 요구되는 영상 데이터 처리에 유용한 작업 환경을 제공할 수 있다.According to the embodiment of FIG. 12 , it is possible to stably process image data in multi-threads on a web browser without overflow of the message queue 210 . Accordingly, the present invention can provide a useful working environment for processing image data requiring real-time performance such as live streaming.

도 12 실시예에서는 제2 쓰레드(200)에서 디패킷화를 수행하는 경우에 대해 살펴보았으나, 이는 설명의 편의를 위해서일 뿐 실시예의 경우로 발명을 한정하는 것은 아니다. 제2 쓰레드(200)가 디패킷화 작업을 수행하는 외에도 웹소켓 클라이언트(101) 및 RTP 클라이언트(102)와 같은 수신 기능 등을 수행하도록 시스템을 구성할 수 있다. In the embodiment of FIG. 12 , a case in which depacketization is performed in the second thread 200 has been described, but this is only for convenience of description, and the invention is not limited to the case of the embodiment. The system may be configured such that the second thread 200 performs reception functions such as the WebSocket client 101 and the RTP client 102 in addition to performing the depacketization operation.

이상의 설명에서, 웹 브라우저 상에서 데이터를 처리하는 장치는 네트워크를 통해 서버나 다른 컴퓨팅 사용자 기기들과 상호작용할 수 있도록 적합한 컴퓨팅 또는 프로세싱 장치를 포함한다. 예를 들면, 웹 브라우저 상에서 데이터를 처리하는 장치는 데스크톱 컴퓨터, 모바일 전화 또는 스마트폰, PDA(personal digital assistant), 랩톱 컴퓨터, 셋톱 박스(set-top box), 디지털 미디어 플레이어, 미디어 동글(media dongle) 및 타블릿 컴퓨터를 포함할 수 있다. In the above description, a device for processing data on a web browser includes a computing or processing device suitable for interacting with a server or other computing user devices via a network. For example, a device that processes data on a web browser is a desktop computer, mobile phone or smart phone, personal digital assistant (PDA), laptop computer, set-top box, digital media player, media dongle. ) and tablet computers.

또한 이상의 설명에서, 웹 브라우저는 구글 크롬, 마이크로소프트 익스플로러, 모질라의 파이어폭스, 애플의 사파리 등, 데스크톱 컴퓨터나 모바일 전화에 탑재되는 일반적으로 알려진 브라우저를 포함할 뿐만 아니라, 웹 브라우저의 리소스나 API를 이용하여 별도로 제작된 소프트웨어 어플리케이션까지 포괄한다. 또한 웹 브라우저는 HTML5를 지원하는 각종 버전의 브라우저를 포함한다. Also, in the description above, web browsers include commonly known browsers installed on desktop computers or mobile phones, such as Google Chrome, Microsoft Explorer, Mozilla's Firefox, and Apple's Safari, as well as access resources or APIs of the web browser. It also includes software applications that have been developed separately. Also, the web browser includes various versions of browsers that support HTML5.

또한 이상의 설명에서, 멀티 쓰레드에서 제1 쓰레드(100)와 제2 쓰레드(200)는 제1 쓰레드(100)가 웹 워커이고 제2 쓰레드(200)가 웹 워커로부터 생성된 서브 워커인 경우를 포함한다. Also, in the above description, the first thread 100 and the second thread 200 in the multi-thread include a case where the first thread 100 is a web worker and the second thread 200 is a sub-worker created from the web worker. do.

본 발명이 속하는 기술분야의 통상의 지식을 가진 자는 본 발명이 그 기술적 사상이나 필수적인 특징을 변경하지 않고서 다른 구체적인 형태로 실시될 수 있다는 것을 이해할 수 있을 것이다. 그러므로 이상에서 기술한 실시예들은 모든 면에서 예시적인 것이며 한정적이 아닌 것으로 이해해야만 한다. 본 발명의 범위는 상기 상세한 설명보다는 후술하는 특허청구범위에 의하여 나타내어지며, 특허청구범위의 의미 및 범위 그리고 그 균등 개념으로부터 도출되는 모든 변경 또는 변형된 형태가 본 발명의 범위에 포함되는 것으로 해석되어야 한다.Those of ordinary skill in the art to which the present invention pertains will understand that the present invention may be embodied in other specific forms without changing the technical spirit or essential features thereof. Therefore, it should be understood that the embodiments described above are illustrative in all respects and not restrictive. The scope of the present invention is indicated by the following claims rather than the above detailed description, and all changes or modifications derived from the meaning and scope of the claims and their equivalents should be interpreted as being included in the scope of the present invention. do.

100: 제1 쓰레드 101: 웹소켓 클라이언트
102: RTP 클라이언트 103: 디코더 모듈
200: 제2 쓰레드 201: 디패킷화 모듈
210, 210a, 210b: 메시지 큐 211: 인큐되는 데이터
212: 디큐되는 데이터 213: 저장된 데이터
220: 이벤트 루프 230: 콜 스택
100: first thread 101: websocket client
102: RTP client 103: decoder module
200: second thread 201: depacketization module
210, 210a, 210b: message queue 211: data to be enqueued
212: data to be dequeued 213: stored data
220: event loop 230: call stack

Claims (20)

웹 브라우저를 구비하는 데이터 처리 장치 상에서, 상기 웹 브라우저가 지원하는 쓰레드를 이용하여 적어도 하나의 프로세서에 의해 수행되는 데이터 처리 방법으로서,
상기 웹 브라우저 상에서 제1 쓰레드를 생성하는 단계;
상기 제1 쓰레드가 제2 쓰레드를 생성하는 단계;
상기 제1 쓰레드가 외부의 서버로부터 웹소켓 연결을 통해 영상 데이터를 수신하는 단계;
상기 제1 쓰레드가 수신된 데이터를 상기 제2 쓰레드에 전달하는 단계;
상기 제2 쓰레드가 상기 전달된 데이터를 상기 제2 쓰레드의 메시지 큐에 저장하는 단계;
상기 제2 쓰레드가 상기 저장된 데이터를 디패킷화하고 상기 디패킷화를 통해 얻어지는 복원된 프레임을 상기 제1 쓰레드로 전달하는 단계; 및
상기 제1 쓰레드가 전달된 프레임을 디코딩하는 단계를 포함하되,
상기 수신된 데이터를 상기 제2 쓰레드에 전달하는 단계는, 상기 제1 쓰레드가 상기 제2 쓰레드의 메시지 큐의 현재 상태에 따라 전달될 데이터의 개수를 조절하고, 상기 개수가 조절된 데이터를 상기 제2 쓰레드에 전달하는 단계를 포함하며,
상기 개수가 조절된 데이터를 전달하는 단계는,
상기 제1 쓰레드가 상기 제2 쓰레드로 복수의 데이터를 개별적으로 전달하는 단계; 및
상기 제1 쓰레드가 상기 제2 쓰레드로부터 상기 메시지 큐의 상태를 나타내는 상태 데이터를 수신한 후에, 상기 복수의 데이터를 병합하여 생성된 중간 데이터를 전달하는 단계를 포함하는, 데이터 처리 방법.
A data processing method performed by at least one processor on a data processing device having a web browser using a thread supported by the web browser,
creating a first thread on the web browser;
generating, by the first thread, a second thread;
receiving, by the first thread, image data from an external server through a web socket connection;
transmitting, by the first thread, the received data to the second thread;
storing, by the second thread, the transferred data in a message queue of the second thread;
depacketizing the stored data by the second thread and transferring the restored frame obtained through the depacketization to the first thread; and
Decoding the transmitted frame by the first thread,
The transmitting of the received data to the second thread may include: the first thread adjusts the number of data to be transferred according to the current state of the message queue of the second thread, and transmits the adjusted data to the second thread. 2 comprising passing to the thread,
The step of transmitting the data whose number is adjusted is,
individually transferring, by the first thread, a plurality of data to the second thread; and
and transmitting, by the first thread, the intermediate data generated by merging the plurality of data after receiving the state data indicating the state of the message queue from the second thread.
제1항에 있어서,
상기 제1 쓰레드로부터 전달받은 데이터에 따라 상기 제2 쓰레드가 상기 메시지 큐의 상태를 확인하는 단계를 더 포함하는, 데이터 처리 방법.
According to claim 1,
The method further comprising the step of the second thread checking the status of the message queue according to the data received from the first thread.
제2항에 있어서,
상기 제2 쓰레드는 단위시간당 상기 메시지 큐에 인큐되는 데이터의 개수와 상기 메시지 큐로부터 디큐되는 데이터의 개수를 비교하여 인큐되는 데이터의 개수가 더 많은 경우, 상기 제1 쓰레드로 상기 상태 데이터를 보내는 단계를 더 포함하는, 데이터 처리 방법.
3. The method of claim 2,
The second thread compares the number of data enqueued in the message queue with the number of data dequeued from the message queue per unit time, and when the number of enqueued data is greater, sending the state data to the first thread Further comprising, a data processing method.
제2항에 있어서,
상기 제2 쓰레드는 상기 메시지 큐에 저장된 데이터의 개수가 일정치를 초과하는 경우, 상기 제1 쓰레드로 상기 상태 데이터를 보내는 단계를 더 포함하되,
상기 일정치는 상기 메시지 큐에 오버플로우가 발생하지 않도록 정해지는 수치인, 데이터 처리 방법.
3. The method of claim 2,
The second thread further comprises the step of sending the state data to the first thread when the number of data stored in the message queue exceeds a predetermined value,
The constant value is a number determined so that an overflow does not occur in the message queue.
제3항 또는 제4항에 있어서, 상기 개수가 조절된 데이터를 전달하는 단계는,
상기 제1 쓰레드가 상기 상태 데이터를 수신한 경우, 각각의 데이터를 개별적으로 전달하는 대신에 복수의 데이터를 병합하여 중간 데이터를 생성하고, 상기 중간 데이터를 상기 제2 쓰레드에 전달하는 단계를 포함하는, 데이터 처리 방법.
5. The method of claim 3 or 4, wherein the transmitting of the adjusted number of data comprises:
When the first thread receives the state data, merging a plurality of data instead of individually transmitting each data to generate intermediate data, and transmitting the intermediate data to the second thread , data processing methods.
◈청구항 6은(는) 설정등록료 납부시 포기되었습니다.◈◈Claim 6 was abandoned when paying the registration fee.◈ 제2항에 있어서,
상기 제2 쓰레드는 상기 메시지 큐에 저장된 데이터의 개수가 포함된 상기 상태 데이터를 상기 제1 쓰레드로 전달하는 단계를 더 포함하는, 데이터 처리 방법.
3. The method of claim 2,
The method of claim 1, further comprising, by the second thread, transmitting the state data including the number of data stored in the message queue to the first thread.
제2항에 있어서,
상기 제2 쓰레드는 단위시간당 상기 메시지 큐에 인큐되는 데이터의 개수와 상기 메시지 큐로부터 디큐되는 데이터의 개수가 포함된 상기 상태 데이터를 상기 제1 쓰레드로 전달하는 단계를 더 포함하는, 데이터 처리 방법.
3. The method of claim 2,
The method further comprising: transmitting, by the second thread, the state data including the number of data enqueued in the message queue and the number of data dequeued from the message queue per unit time to the first thread.
제6항 또는 제7항에 있어서, 상기 개수가 조절된 데이터를 전달하는 단계는,
상기 제1 쓰레드가 상기 상태 데이터로부터 상기 메시지 큐에 적재된 메시지의 개수를 판단하고, 상기 적재된 메시지의 개수가 일정치를 초과한다고 판단한 경우, 각각의 데이터를 개별적으로 전달하는 대신에 복수의 데이터를 병합하여 중간 데이터를 생성하고, 상기 중간 데이터를 상기 제2 쓰레드에 전달하는 단계를 포함하되,
상기 일정치는 상기 메시지 큐에 오버플로우가 발생하지 않도록 정해지는 수치인, 데이터 처리 방법.
The method of claim 6 or 7, wherein the transmitting of the adjusted number of data comprises:
When the first thread determines the number of messages loaded into the message queue from the status data, and determines that the number of loaded messages exceeds a predetermined value, instead of individually delivering each data, a plurality of data merging to generate intermediate data, and transmitting the intermediate data to the second thread,
The constant value is a number determined so that an overflow does not occur in the message queue.
삭제delete ◈청구항 10은(는) 설정등록료 납부시 포기되었습니다.◈◈Claim 10 was abandoned when paying the registration fee.◈ 제1항에 있어서,
상기 웹 브라우저는 HTML5를 지원하는, 데이터 처리 방법.
According to claim 1,
The web browser supports HTML5, data processing method.
◈청구항 11은(는) 설정등록료 납부시 포기되었습니다.◈◈Claim 11 was abandoned when paying the registration fee.◈ 제1항에 있어서,
상기 제2 쓰레드는 적어도 하나 이상의 쓰레드로 구성되는, 데이터 처리 방법.
According to claim 1,
The second thread is configured of at least one or more threads.
제1항에 있어서,
상기 제1 쓰레드는 웹 브라우저에서 사용자 인터페이스 스크립트를 실행하는 메인 쓰레드이고, 상기 제2 쓰레드는 상기 메인 쓰레드로부터 생성된 웹 워커 쓰레드인, 데이터 처리 방법.
According to claim 1,
The first thread is a main thread that executes a user interface script in a web browser, and the second thread is a web worker thread generated from the main thread.
제1항에 있어서, 상기 수신된 데이터를 전달하는 단계와 상기 개수가 조절된 데이터를 전달하는 단계는,
상기 제1 쓰레드가 상기 제2 쓰레드에 postMessage로 데이터를 전달하는 단계인, 데이터 처리 방법.
The method of claim 1, wherein the step of delivering the received data and the step of delivering the adjusted data comprises:
The method of claim 1, wherein the first thread transmits data to the second thread as a postMessage.
제1항에 있어서,
상기 제1 쓰레드 및 상기 제2 쓰레드는 자바스크립트로 작성된 스크립트를 실행하는, 데이터 처리 방법.
According to claim 1,
The first thread and the second thread execute a script written in JavaScript, a data processing method.
제1항에 있어서,
상기 제1 쓰레드는 메인 쓰레드로부터 생성된 웹 워커(web worker)이고, 상기 제2 쓰레드는 상기 웹 워커로부터 생성된 서브 워커(sub worker)인, 데이터 처리 방법.
According to claim 1,
The first thread is a web worker (web worker) generated from the main thread, the second thread is a sub worker (sub worker) generated from the web worker, data processing method.
◈청구항 16은(는) 설정등록료 납부시 포기되었습니다.◈◈Claim 16 was abandoned when paying the registration fee.◈ 제1항에 있어서,
상기 수신된 데이터는 패킷화된 영상 데이터인, 데이터 처리 방법.
According to claim 1,
wherein the received data is packetized image data.
삭제delete 삭제delete 삭제delete 제1항에 있어서,
상기 개수가 조절된 데이터는 복수의 패킷화된 영상 데이터의 헤더정보를 이용하여 상기 복수의 패킷화된 영상 데이터를 병합하여 생성된 데이터인, 데이터 처리 방법.
According to claim 1,
The data processing method according to claim 1, wherein the data whose number is adjusted is data generated by merging the plurality of packetized image data using header information of the plurality of packetized image data.
KR1020170096216A 2017-07-28 2017-07-28 Method for processing data by use of multi-threads on a web browser KR102384249B1 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
KR1020170096216A KR102384249B1 (en) 2017-07-28 2017-07-28 Method for processing data by use of multi-threads on a web browser

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
KR1020170096216A KR102384249B1 (en) 2017-07-28 2017-07-28 Method for processing data by use of multi-threads on a web browser

Publications (2)

Publication Number Publication Date
KR20190012742A KR20190012742A (en) 2019-02-11
KR102384249B1 true KR102384249B1 (en) 2022-04-08

Family

ID=65370444

Family Applications (1)

Application Number Title Priority Date Filing Date
KR1020170096216A KR102384249B1 (en) 2017-07-28 2017-07-28 Method for processing data by use of multi-threads on a web browser

Country Status (1)

Country Link
KR (1) KR102384249B1 (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR20210075312A (en) 2019-12-13 2021-06-23 주식회사 한국오픈솔루션 Method for processing data by use of thread

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2001117888A (en) * 1999-10-14 2001-04-27 Fujitsu Ltd Device and method for managing message queue
KR101286700B1 (en) * 2006-11-06 2013-07-16 삼성전자주식회사 Apparatus and method for load balancing in multi core processor system

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR20090067017A (en) * 2007-12-20 2009-06-24 중앙대학교 산학협력단 A frame-based selective encryption methoad and apparatus for real time video transmission on voip
US9152468B2 (en) * 2010-10-25 2015-10-06 Samsung Electronics Co., Ltd. NUMA aware system task management
KR101319243B1 (en) * 2011-08-24 2013-10-16 연세대학교 산학협력단 A method for providing web-page and a computer-readable recording medium recording program for implementing the method
KR102185692B1 (en) 2013-02-15 2020-12-02 삼성전자주식회사 Terminal appratus, server, browser of terminal appratus operaing system and browser operaing method of terminal apparatus

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2001117888A (en) * 1999-10-14 2001-04-27 Fujitsu Ltd Device and method for managing message queue
KR101286700B1 (en) * 2006-11-06 2013-07-16 삼성전자주식회사 Apparatus and method for load balancing in multi core processor system

Also Published As

Publication number Publication date
KR20190012742A (en) 2019-02-11

Similar Documents

Publication Publication Date Title
US20140026142A1 (en) Process Scheduling to Maximize Input Throughput
US8856407B2 (en) USB redirection for write streams
US20110022643A1 (en) Dynamic media content previews
US20170344439A1 (en) System and method for input data fault recovery in a massively parallel real time computing system
US20130132960A1 (en) Usb redirection for read transactions
US9842083B2 (en) Using completion queues for RDMA event detection
US20130046878A1 (en) Asynchronous request interception for testing a request life-cycle
US9176793B2 (en) Managed channel for asynchronous requests
US10541927B2 (en) System and method for hardware-independent RDMA
US11836047B2 (en) Small file restore performance in a deduplication file system
US20180270299A1 (en) System and method for producing api-throttle and back-pressure avoidance among clients using distributed asynchronous components
JP2013080404A (en) System, computer, method, and program which call java method on client
US20130132618A1 (en) Usb redirection for interrupt transactions
KR102384249B1 (en) Method for processing data by use of multi-threads on a web browser
US11381630B2 (en) Transmitting data over a network in representational state transfer (REST) applications
US9806933B2 (en) Component loading based on user interactions
US9910834B2 (en) Converting terminal-based legacy applications to web-based applications
CN111652691A (en) Order information processing method and device and electronic equipment
CN113722115A (en) Method, device, equipment and computer readable medium for calling interface
CN111427654A (en) Instruction processing method and device
Zhang et al. Improving asynchronous invocation performance in client-server systems
US8185898B2 (en) Method of streaming remote procedure invocation for multi-core systems
EP3872630A2 (en) Request processing method and apparatus, electronic device, and computer storage medium
US11836054B2 (en) File restore performance in a deduplication file system using adaptive prefetching
US11245772B1 (en) Dynamic representation of remote computing environment

Legal Events

Date Code Title Description
N231 Notification of change of applicant
A201 Request for examination
E902 Notification of reason for refusal
AMND Amendment
E601 Decision to refuse application
X091 Application refused [patent]
AMND Amendment
X701 Decision to grant (after re-examination)
GRNT Written decision to grant