SlideShare ist ein Scribd-Unternehmen logo
1 von 19
The Art of Computer Programming   1.4.2 Coroutine 아꿈사  발표자  :  박솔이 2011.03.26 ,[object Object],[object Object],[object Object],[object Object]
코루틴의 의미 서브루틴과 코루틴의 차이  1 서브루틴 관리자 와  팀원 의 관계 서로  비대칭적 인 관계 코루틴 팀원 과  팀원 의 관계 서로  대칭적 인 관계
코루틴의 의미 서브루틴과 코루틴의 차이  2 루틴 - 서브루틴  연계 서브루틴은 일반적으로  고정된 시작 지점 에서  실행 됨 . 코루틴 - 코루틴  연계 마지막으로  중단되었던 지점 다음의 장소에서  재개 됨 .
코루틴의 의미 간단한 코루틴의 예 A  STJ  BX AX  JMP  A1 B  STJ  AX BX  JMP  B1 Coroutine A A1  …. … . A2  JMP  B Coroutine B B1  …. … . B2  JMP  A
코루틴의 의미 간단한 코루틴의 예 A  STJ  BX AX  JMP  A1 B  STJ  AX BX  JMP  B1 Coroutine A A1  …. … . A2  JMP  B Coroutine B B1  …. … . B2  JMP  A
코루틴의 의미 간단한 코루틴의 예 A  STJ  BX AX  JMP  A2+1 B  STJ  AX BX  JMP  B1 Coroutine A A1  …. … . A2  JMP  B Coroutine B B1  …. … . B2  JMP  A
코루틴의 의미 간단한 코루틴의 예 A  STJ  BX AX  JMP  A2+1 B  STJ  AX BX  JMP  B1 Coroutine A A1  …. … . A2  JMP  B Coroutine B B1  …. … . B2  JMP  A
코루틴의 의미 간단한 코루틴의 예 A  STJ  BX AX  JMP  A2+1 B  STJ  AX BX  JMP  B1 Coroutine A A1  …. … . A2  JMP  B Coroutine B B1  …. … . B2  JMP  A
코루틴의 의미 간단한 코루틴의 예 A  STJ  BX AX  JMP  A2+1 B  STJ  AX BX  JMP  B2+1 Coroutine A A1  …. … . A2  JMP  B Coroutine B B1  …. … . B2  JMP  A
코루틴의 의미 간단한 코루틴의 예 A  STJ  BX AX  JMP  A2+1 B  STJ  AX BX  JMP  B2+1 Coroutine A A1  …. … . A2  JMP  B Coroutine B B1  …. … . B2  JMP  A
코루틴의 예 실제 코루틴의 예  :  번역 프로그램 입력을 특정한 규칙에 따라 번역하여 출력하는 프로그램 Input :  A 2B 5E 34 26 F G 0Z Y W 32 10 P Q 89 R. Output:  A BB B EE EEE E 44 44 6 66 F  G Z Y  W 22 22 0 0 P Q  999 999 999  R. 규칙 1.  현재 문자가 숫자  0~9  중 하나이면 ( 이 숫자를  n 이라고 할때 ,)  그 다음 문자를 영문자이든 숫자이든 상관없이  (n+1) 번 반복한다 . 규칙 2.  현재 문자가 숫자가 아니면 그 문자 그대로 출력한다 . 규칙 3.  번역 결과를 세 글자 단위로 출력한다 . 규칙 4.  입력 문자가 마침표가 나올 때까지 번역한다 .
코루틴의 예 실제 코루틴의 예  :  번역 프로그램 Coroutine INPUT 입력문자를 읽고 규칙 1,2 에 따라서 번역하고  출력하는 코루틴 Coroutine OUTPUT 번역된 문자를 읽고  규칙  3,4 에 따라서  출력하는 코루틴 Subroutine NEXTCHAR 입력에서 공백이 아닌 문자를 찾고 그 다음 문자를  레지스터  A 에 넣는 서브루틴 Mainroutine INIT & LINKAGE 프로그램을 초기화하고 코루틴을 연계하는 주루틴
코루틴의 예 실제 코루틴의 예  :  번역 프로그램 01 * SUBROUTINE FOR CHARACTER INPUT 02 READER EQU 16 03 INPUT ORIG *+16 04 NEXTCHAR STJ 9F 05 JXNZ 3F 06 1H J6N 2F 07 IN INPUT(READER) 08 JBUS *(READER) 09 ENN6 16 10 2H LDX INPUT+16,6 11 INC6 1 12 3H ENTA 0 13 SLAX 1 14 9H JANZ * 15 JMP NEXTCHAR+1
코루틴의 예 실제 코루틴의 예  :  번역 프로그램 16 * FIRST COROUTINE 17 2H INCA 30 18 JMP OUT 19 JMP NEXTCHAR 20 DECA 30 21 JAN 2B 22 CMPA =10= 23 JGE 2B 24 STA *+1(0:2) 25 ENT5 * 26 JMP NEXTCHAR 27 JMP OUT 28 DEC5 1 29 J5NN *-2 30 JMP IN1
코루틴의 예 실제 코루틴의 예  :  번역 프로그램 31 * SECOND COROUTINE 32 ALF 33 OUTPUT ORIG *+16 34 PUNCH EQU 17 35 OUT1 ENT4 -16 36 ENT1 OUTPUT 37 MOVE -1,1(16) 38 1H JMP IN 39 STA OUTPUT+16,4(1:1) 40 CMPA PERIOD 41 JE 9F 42 JMP IN 43 STA OUTPUT+16,4(2:2) 44 CMPA PERIOD 45 JE 9F 46 JMP IN 47 STA OUTPUT+16,4(3:3) 48 CMPA PERIOD 49 JE 9F 50 INC4 1 51 J4N 1B 52 9H OUT OUTPUT(PUNCH) 53 JBUS *(PUNCH) 54 JNE OUT1 55 HLT 56 PERIOD ALF .
코루틴의 예 실제 코루틴의 예  :  번역 프로그램 57 * INITIALIZATION AND LINKAGE 58 START ENT6 0 59 ENTX 0 60 JMP OUT1 61 OUT STJ INX 62 OUTX JMP OUT1 63 IN STJ OUTX 64 INX JMP IN1 65 END START
코루틴의 응용 코루틴과 다중패스 알고리즘  1 IN TAPE 1 Pass A TAPE 1 TAPE 2 Pass B TAPE 2 TAPE 3 Pass C TAPE 3 OUT Pass D IN Coroutine A Coroutine B Coroutine C Coroutine D OUT 다중 패스 알고리즘 분할이 쉽다 . 한번에 한 프로그램만  메모리에 존재 단일 패스 알고리즘 입출력 시간이 빠르다 . 모든 코루틴이 메모리에 존재
코루틴의 응용 코루틴과 다중패스 알고리즘  2 코루틴 응용 프로그램을 다중패스 알고리즘으로  변환하는 것이 항상 가능하지는 않다 . example) 코루틴  B 가  A 로부터 입력을 얻음과 동시에 다시  중요한 정보를  A 로 보내야 하는 상황 할머니 한 분이 버스에 올랐다 . “ 꼬마야 파사데나 거리로 가는데 ,  언제 내려야 하니 ?” 꼬마 . “ 저를 보고 계시다가요 .  저보다 두 정거장 전에서 내리세요 .”
Thank you 

Weitere ähnliche Inhalte

Empfohlen

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

Empfohlen (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

Taocp1.4.2

  • 1.
  • 2. 코루틴의 의미 서브루틴과 코루틴의 차이 1 서브루틴 관리자 와 팀원 의 관계 서로 비대칭적 인 관계 코루틴 팀원 과 팀원 의 관계 서로 대칭적 인 관계
  • 3. 코루틴의 의미 서브루틴과 코루틴의 차이 2 루틴 - 서브루틴 연계 서브루틴은 일반적으로 고정된 시작 지점 에서 실행 됨 . 코루틴 - 코루틴 연계 마지막으로 중단되었던 지점 다음의 장소에서 재개 됨 .
  • 4. 코루틴의 의미 간단한 코루틴의 예 A STJ BX AX JMP A1 B STJ AX BX JMP B1 Coroutine A A1 …. … . A2 JMP B Coroutine B B1 …. … . B2 JMP A
  • 5. 코루틴의 의미 간단한 코루틴의 예 A STJ BX AX JMP A1 B STJ AX BX JMP B1 Coroutine A A1 …. … . A2 JMP B Coroutine B B1 …. … . B2 JMP A
  • 6. 코루틴의 의미 간단한 코루틴의 예 A STJ BX AX JMP A2+1 B STJ AX BX JMP B1 Coroutine A A1 …. … . A2 JMP B Coroutine B B1 …. … . B2 JMP A
  • 7. 코루틴의 의미 간단한 코루틴의 예 A STJ BX AX JMP A2+1 B STJ AX BX JMP B1 Coroutine A A1 …. … . A2 JMP B Coroutine B B1 …. … . B2 JMP A
  • 8. 코루틴의 의미 간단한 코루틴의 예 A STJ BX AX JMP A2+1 B STJ AX BX JMP B1 Coroutine A A1 …. … . A2 JMP B Coroutine B B1 …. … . B2 JMP A
  • 9. 코루틴의 의미 간단한 코루틴의 예 A STJ BX AX JMP A2+1 B STJ AX BX JMP B2+1 Coroutine A A1 …. … . A2 JMP B Coroutine B B1 …. … . B2 JMP A
  • 10. 코루틴의 의미 간단한 코루틴의 예 A STJ BX AX JMP A2+1 B STJ AX BX JMP B2+1 Coroutine A A1 …. … . A2 JMP B Coroutine B B1 …. … . B2 JMP A
  • 11. 코루틴의 예 실제 코루틴의 예 : 번역 프로그램 입력을 특정한 규칙에 따라 번역하여 출력하는 프로그램 Input : A 2B 5E 34 26 F G 0Z Y W 32 10 P Q 89 R. Output: A BB B EE EEE E 44 44 6 66 F G Z Y W 22 22 0 0 P Q 999 999 999 R. 규칙 1. 현재 문자가 숫자 0~9 중 하나이면 ( 이 숫자를 n 이라고 할때 ,) 그 다음 문자를 영문자이든 숫자이든 상관없이 (n+1) 번 반복한다 . 규칙 2. 현재 문자가 숫자가 아니면 그 문자 그대로 출력한다 . 규칙 3. 번역 결과를 세 글자 단위로 출력한다 . 규칙 4. 입력 문자가 마침표가 나올 때까지 번역한다 .
  • 12. 코루틴의 예 실제 코루틴의 예 : 번역 프로그램 Coroutine INPUT 입력문자를 읽고 규칙 1,2 에 따라서 번역하고 출력하는 코루틴 Coroutine OUTPUT 번역된 문자를 읽고 규칙 3,4 에 따라서 출력하는 코루틴 Subroutine NEXTCHAR 입력에서 공백이 아닌 문자를 찾고 그 다음 문자를 레지스터 A 에 넣는 서브루틴 Mainroutine INIT & LINKAGE 프로그램을 초기화하고 코루틴을 연계하는 주루틴
  • 13. 코루틴의 예 실제 코루틴의 예 : 번역 프로그램 01 * SUBROUTINE FOR CHARACTER INPUT 02 READER EQU 16 03 INPUT ORIG *+16 04 NEXTCHAR STJ 9F 05 JXNZ 3F 06 1H J6N 2F 07 IN INPUT(READER) 08 JBUS *(READER) 09 ENN6 16 10 2H LDX INPUT+16,6 11 INC6 1 12 3H ENTA 0 13 SLAX 1 14 9H JANZ * 15 JMP NEXTCHAR+1
  • 14. 코루틴의 예 실제 코루틴의 예 : 번역 프로그램 16 * FIRST COROUTINE 17 2H INCA 30 18 JMP OUT 19 JMP NEXTCHAR 20 DECA 30 21 JAN 2B 22 CMPA =10= 23 JGE 2B 24 STA *+1(0:2) 25 ENT5 * 26 JMP NEXTCHAR 27 JMP OUT 28 DEC5 1 29 J5NN *-2 30 JMP IN1
  • 15. 코루틴의 예 실제 코루틴의 예 : 번역 프로그램 31 * SECOND COROUTINE 32 ALF 33 OUTPUT ORIG *+16 34 PUNCH EQU 17 35 OUT1 ENT4 -16 36 ENT1 OUTPUT 37 MOVE -1,1(16) 38 1H JMP IN 39 STA OUTPUT+16,4(1:1) 40 CMPA PERIOD 41 JE 9F 42 JMP IN 43 STA OUTPUT+16,4(2:2) 44 CMPA PERIOD 45 JE 9F 46 JMP IN 47 STA OUTPUT+16,4(3:3) 48 CMPA PERIOD 49 JE 9F 50 INC4 1 51 J4N 1B 52 9H OUT OUTPUT(PUNCH) 53 JBUS *(PUNCH) 54 JNE OUT1 55 HLT 56 PERIOD ALF .
  • 16. 코루틴의 예 실제 코루틴의 예 : 번역 프로그램 57 * INITIALIZATION AND LINKAGE 58 START ENT6 0 59 ENTX 0 60 JMP OUT1 61 OUT STJ INX 62 OUTX JMP OUT1 63 IN STJ OUTX 64 INX JMP IN1 65 END START
  • 17. 코루틴의 응용 코루틴과 다중패스 알고리즘 1 IN TAPE 1 Pass A TAPE 1 TAPE 2 Pass B TAPE 2 TAPE 3 Pass C TAPE 3 OUT Pass D IN Coroutine A Coroutine B Coroutine C Coroutine D OUT 다중 패스 알고리즘 분할이 쉽다 . 한번에 한 프로그램만 메모리에 존재 단일 패스 알고리즘 입출력 시간이 빠르다 . 모든 코루틴이 메모리에 존재
  • 18. 코루틴의 응용 코루틴과 다중패스 알고리즘 2 코루틴 응용 프로그램을 다중패스 알고리즘으로 변환하는 것이 항상 가능하지는 않다 . example) 코루틴 B 가 A 로부터 입력을 얻음과 동시에 다시 중요한 정보를 A 로 보내야 하는 상황 할머니 한 분이 버스에 올랐다 . “ 꼬마야 파사데나 거리로 가는데 , 언제 내려야 하니 ?” 꼬마 . “ 저를 보고 계시다가요 . 저보다 두 정거장 전에서 내리세요 .”