GCD
(Grand Central Dispatch)
iOS & OS X 멀티스레딩 기법
2013. 11.
아프리카TV 기술연구소 모바일개발팀
전임연구원 정창욱
Concurrent, Multi threading and processing
● OpenMP
● OpenCL
● GCD
GCD의 특징
● Multi Thread and Processing 코드를 간결하
고 쉽게 구현 가능
● C 언어로 되어 있는 Thread 관리 기술
● C 언어의 Block 기반으로 실행
● OS가 지능적으로 Task...
GCD - Dispatch Queue Type
OS kernal

Dispatch Queue

4

3

2

1

run
worker thread
GCD - Dispatch Queue Type
Serial Dispatch Queue

3

2

1

run
worker thread

Concurrent Dispatch Queue

run
worker thread
...
GCD - Dispatch Queue Type
Serial - Main Dispatch Queue
Concurrent - Global Dispatch Queue
GCD - 생성 및 얻기
● dispatch_queue_t dispatch_queue_create(
const char *label,
dispatch_queue_attr_t attr);
● dispatch_queue_t...
GCD - 실행 및 제어
●

●

●

void dispatch_async(
dispatch_queue_t queue,
dispatch_block_t block);
void dispatch_barrier_async(
...
GCD - 실행 및 제어
●

void dispatch_apply(
size_t iterations,
dispatch_queue_t queue,
void (^block)(size_t));
GCD - 실행 및 제어
● void dispatch_set_target_queue(
dispatch_object_t object,
dispatch_queue_t queue);
● void dispatch_after(
...
GCD - 실행 및 제어
● void dispatch_group_async(
dispatch_group_t group,
dispatch_queue_t queue,
dispatch_block_t block);
● void...
GCD - 실행 및 제어
● void dispatch_suspend(dispatch_object_t object);
● void dispatch_resume(dispatch_object_t object);
● void ...
Gcd(i os & os x 멀티스레딩 기법)
Gcd(i os & os x 멀티스레딩 기법)
Gcd(i os & os x 멀티스레딩 기법)
Gcd(i os & os x 멀티스레딩 기법)
Gcd(i os & os x 멀티스레딩 기법)
Gcd(i os & os x 멀티스레딩 기법)
Upcoming SlideShare
Loading in …5
×

Gcd(i os & os x 멀티스레딩 기법)

651 views

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
651
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
2
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Gcd(i os & os x 멀티스레딩 기법)

  1. 1. GCD (Grand Central Dispatch) iOS & OS X 멀티스레딩 기법 2013. 11. 아프리카TV 기술연구소 모바일개발팀 전임연구원 정창욱
  2. 2. Concurrent, Multi threading and processing ● OpenMP ● OpenCL ● GCD
  3. 3. GCD의 특징 ● Multi Thread and Processing 코드를 간결하 고 쉽게 구현 가능 ● C 언어로 되어 있는 Thread 관리 기술 ● C 언어의 Block 기반으로 실행 ● OS가 지능적으로 Task(Thread) 스케쥴링
  4. 4. GCD - Dispatch Queue Type OS kernal Dispatch Queue 4 3 2 1 run worker thread
  5. 5. GCD - Dispatch Queue Type Serial Dispatch Queue 3 2 1 run worker thread Concurrent Dispatch Queue run worker thread 3 2 1 run worker thread run worker thread
  6. 6. GCD - Dispatch Queue Type Serial - Main Dispatch Queue Concurrent - Global Dispatch Queue
  7. 7. GCD - 생성 및 얻기 ● dispatch_queue_t dispatch_queue_create( const char *label, dispatch_queue_attr_t attr); ● dispatch_queue_t dispatch_get_main_queue(void); ● dispatch_queue_t dispatch_get_global_queue( long priority, unsigned long flags);
  8. 8. GCD - 실행 및 제어 ● ● ● void dispatch_async( dispatch_queue_t queue, dispatch_block_t block); void dispatch_barrier_async( dispatch_queue_t queue, dispatch_block_t block); void dispatch_sync( dispatch_queue_t queue, dispatch_block_t block); Concurrent dispatch queue dispatch_async dispatch_async task task task task task task task dispatch_barrier_async 시간
  9. 9. GCD - 실행 및 제어 ● void dispatch_apply( size_t iterations, dispatch_queue_t queue, void (^block)(size_t));
  10. 10. GCD - 실행 및 제어 ● void dispatch_set_target_queue( dispatch_object_t object, dispatch_queue_t queue); ● void dispatch_after( dispatch_time_t when, dispatch_queue_t queue, dispatch_block_t block);
  11. 11. GCD - 실행 및 제어 ● void dispatch_group_async( dispatch_group_t group, dispatch_queue_t queue, dispatch_block_t block); ● void dispatch_group_notify( dispatch_group_t group, dispatch_queue_t queue, dispatch_block_t block);
  12. 12. GCD - 실행 및 제어 ● void dispatch_suspend(dispatch_object_t object); ● void dispatch_resume(dispatch_object_t object); ● void dispatch_once( dispatch_once_t *predicate, dispatch_block_t block);

×