기본 콘텐츠로 건너뛰기

추천 게시물

[Go] 고루틴

런타임(Runtime) visual code에서 브라우저 실행 단축키: Alt+B Go runtime은 메모리 관리, 가비지 수집, 동시성을 포함하여 Go 프로그림의 실행을 관리하는 역할을 합니다. 이 문서에서는 Go runtime을 자세히 살펴보고 아키텍초, 특성과 장점을 살펴봅니다. Go Runtime Architecture Go runtime은 모듈식이고 유연하게 설계되었으며 개발자가 특정 요구사항에 따라 동작을 사용자 정의할 수 있는 계층적 아키텍쳐를 갖추고 있습니다. 런타임은 스케줄러(schedualer), 가비지 수집기(garbage collector), 메모리 할당자(memory alllocator) 및 스택관리(stack management)를 포함한 어려 핵심 구성 요소로 구성됩니다. Schedualer Go 런타임의 핵심은 고루틴의 실행을 관리하는 스케줄러입니다. 고루틴은 효율적인 동시성을 가능하게 하는 가벼운 스레드입니다. 스케줄러는 사용 가능한 스레드에 고루틴을 분산하고, 스레드 로컬 스토리지를 관리하고, I/O 작업을 조정하는 역할을 합니다. thread(스레드): 프로그램 내에서 실행되는 흐름의 단위로 동시에 여러 작업이나 프로그램을 실행하는 것입니다. 즉, 코드를 실행할 수 있는 각 단위를 스레드라고 합니다. 고루틴(goroutine): Go 언어로 동시에 실행되는 모든 활동을 의미합니다. 고루틴을 만드는 비용을 스레드에 비해 매우 적기 떄문에 경량 스레드라고 합니다. 모든 프로그램은 적어도 하나의 main() 함수라는 고루틴을 포함하고 고루틴은 항상 백그라운드에서 작동합니다. 메인함수가 종료되면 모든 고루틴은 종료됩니다. 그러므로 고루틴보다 main이 먼저 종료되는 것을 방지해야 합니다. Go 스케줄러는 매우 효율적이고 확장 가능하도록 설계되어 많은 수의 동시 고루틴을 손쉽게 처리할 수 있습니다. 스레드 간에 부하를 분산하여 경합을 최소화하고 성능을 개선하는 작업 훔치기 알고리즘을 사용합니다...

3. Vecctor

Basic data structure in R -  c(data) function : to generate  the dataset -  Basic  structure : an atomic vector, -  Multiple atomic vectors: list.  -  Generating numerical types in atomic vectors:    using function such as  clones (start: end), seq (start, end, by or length.out), rep (data, Number of repeats) The function seq() creates a sequence with interval determined by parameter ‘by’ and automatically generates a sequence of numbers between start and end as specified number by the parameter, 'length.out'. Function rep() repeat data as the specified number of times. > 1 : 10  [1]  1  2  3  4  5  6  7  8  9 10 > seq ( 1 , 10 , by= 2 ) [1] 1 3 5 7 9 > seq ( 1 , 10 , length.out= 3 ) [1]  1.0  5.5 10.0 > rep ( 1 , 3 ) [1] 1 1 1 > rep ( c ( 2 , 3 ), c ( 2 , 3 )) [1] 2 2 3 3 3 > rep ( 'a' , 3 ) ...

Coercion of data types

Coercion of data types is also performed by functions as.character(), as.double(), as.integer(), and as.logical() .   For character types with the highest level, coercion returns NA (Not Available). That is, no coercion works. However, coercion is smooth among the forms other than the character type. In particular, considering the fact that T / F is replaced by 1 and 0 in the case of the logical type, conversion into a numeric form is natural.  What about other types of logical type conversions?  In practice, any number other than 0 is treated as TRUE. > as.character ( 1 ) [1] "1" > as.integer ( 'a' ) Warning: NA generated by forced cast [1] NA > as.double (T) [1] 1 > as.logical ( - 210 ) [1] TRUE

Data Type intro_R

Data Type 1 There are two types of data. Numerical and character types. The character type in R consists of a single quotation mark (' ') or a double quotation mark (" "). > 23  #numerical type [1] 23 > 'Baby' [1] "Baby" #character type > "1" #character type [1] "1" The dimensions of the data and the types of each value in the data are homogeneous is the basis for identifying the data structure of R. dimension homogeneous heterogeneous 1 dimension Atom vector List 2 dimension Matrix dataframe 3 dimension array _ > x<-1:10 > y<-rnorm(5) > z<-c('a','c', 'f') > x1<-list(x, y, z) > names(x1)<-c('num', 'random', 'char') > str(x1) List of 3  $ num   : int [1:10] 1 2 3 4 5 6 7 8 9 10  $ random: num [1:5] -0.8882 -0.2021 1.0884...