SlideShare a Scribd company logo
1 of 17
3.4 병행성 : 시간은 중요하다. 
Structure and Interpretation of Computer Programs 
2014.11.22 
aceigy6322@gmail.com
• 물체가 시간에 따라 달라지는 상태를 가짐. 
• 덮어 쓰기 연산으로 변수 값이 바뀔때마다 
시간의 변화를 나타냄. 
• 상태의 변화는 한번에 하나씩 바뀌는게 아 
니라 병행으로 바뀐다고 봄.
(Withdraw 25) 
- 75 
(Withdraw 25) 
- 50
병행 시스템에서 시간의 성질 
• 사건의 일어나는 차례 
차례가 바로 시간. 
• 같은 시간에 상태하나 
를 여러 프로세스가 
덮어쓰려해서 문제.
병행성을 다스리는 방법 
• 상태 변화가 병행으로 일어 날때, 그 시스 
템이 제대로 돌아간다는 사실을 보장할 방 
법이 필요. 
• 제약 조건을 걸어줌. 
• 줄 세우개(Serializer)
줄 세우개(Serializer) 
• 프로시저들을 여러 그룹으로 나누고, 같은 
그룹에 속하는 프로시저들이 동시에 실행 
되는 일이 없도록 하는것.
한 상태를 여럿이 같이 쓸때 그 차 
례를 정하는 방법 
(define x 10) 
(parallel-execute ( lambda () (set! X (* x x))) 
( lambda () (set! X (+ x 1))))
(define x 10) 
(define s (make-serializer)) 
(parallel-execute ( s (lambda () (set! X (* x 
x)))) 
( s (lambda () (set! X (+ x 
1)))))
여러자원을 함께 쓰는 문제 
(define (exchange account1 account2) 
(let ((difference (- (account1 ‘balance) 
(account2 ‘balance)))) 
((account1 ‘withdraw) difference) 
((account2 ‘deposit) difference)))
(define (serialized-exchange account1 
account2) 
(let ((serializer1 (account1 ‘serializer’)) 
(serializer2 (account2 ‘seralizer’))) 
((serializer1 (serializer2 exchange)) 
account1 
account2)))
줄세우기 만들기 
(define (make-serializer) 
(let ((mutex (make-mutex))) 
(lambda (p) 
(define (serialized-p . Args) 
(mutex ‘acquire) 
(let ((val (apply p args))) 
(mutex ‘release) 
val)) 
serialized-p)))
(define (make-mutex) 
(let ((cell (list false))) 
(define (the-mutex m) 
(cond ((eq? m ‘acquire) 
(if (test-and-set! Cell) 
(the-mutex ‘acquire))) 
(eq? m ‘release) (clear! Cell)))) 
the-mutex)) 
(define (clear! Cell) 
(set-car! Cell false))
(define (test-and-set! Cell) 
(if (car cell) 
true 
(begin (set-car! Cell true) 
false)))
엇갈림(deadlock) 
• 여러 프로세스가 다른 프로세스를 지켜보 
면서 아무것도 하지 못하고 끝없이 기다려 
야 하는 상태. 
• 공유자원에 번호를 매겨놓고 차례대로 쓰 
는 기법 
• 엇갈림 벗어나기 기법(deadlock-recovery)
동기점 맞추기(barrier synchronization) 
• 여러 병행 프로세스가 실행되는 중에 동기 
를 맞추어야 할 어떤 지점에 다다르면, 모 
든 프로세스가 같은 지점에 이를때까지 멈 
춤.
Referance 
• 컴퓨터 프로그램의 구조와 해석 2/E 
– 헤럴드에빌슨, 제럴드 제이 서스먼, 줄리 서스먼 지음. 인사이트.

More Related Content

Featured

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
 

Featured (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...
 

3.4병행성 시간은 중요하다.

  • 1. 3.4 병행성 : 시간은 중요하다. Structure and Interpretation of Computer Programs 2014.11.22 aceigy6322@gmail.com
  • 2. • 물체가 시간에 따라 달라지는 상태를 가짐. • 덮어 쓰기 연산으로 변수 값이 바뀔때마다 시간의 변화를 나타냄. • 상태의 변화는 한번에 하나씩 바뀌는게 아 니라 병행으로 바뀐다고 봄.
  • 3. (Withdraw 25) - 75 (Withdraw 25) - 50
  • 4. 병행 시스템에서 시간의 성질 • 사건의 일어나는 차례 차례가 바로 시간. • 같은 시간에 상태하나 를 여러 프로세스가 덮어쓰려해서 문제.
  • 5. 병행성을 다스리는 방법 • 상태 변화가 병행으로 일어 날때, 그 시스 템이 제대로 돌아간다는 사실을 보장할 방 법이 필요. • 제약 조건을 걸어줌. • 줄 세우개(Serializer)
  • 6.
  • 7. 줄 세우개(Serializer) • 프로시저들을 여러 그룹으로 나누고, 같은 그룹에 속하는 프로시저들이 동시에 실행 되는 일이 없도록 하는것.
  • 8. 한 상태를 여럿이 같이 쓸때 그 차 례를 정하는 방법 (define x 10) (parallel-execute ( lambda () (set! X (* x x))) ( lambda () (set! X (+ x 1))))
  • 9. (define x 10) (define s (make-serializer)) (parallel-execute ( s (lambda () (set! X (* x x)))) ( s (lambda () (set! X (+ x 1)))))
  • 10. 여러자원을 함께 쓰는 문제 (define (exchange account1 account2) (let ((difference (- (account1 ‘balance) (account2 ‘balance)))) ((account1 ‘withdraw) difference) ((account2 ‘deposit) difference)))
  • 11. (define (serialized-exchange account1 account2) (let ((serializer1 (account1 ‘serializer’)) (serializer2 (account2 ‘seralizer’))) ((serializer1 (serializer2 exchange)) account1 account2)))
  • 12. 줄세우기 만들기 (define (make-serializer) (let ((mutex (make-mutex))) (lambda (p) (define (serialized-p . Args) (mutex ‘acquire) (let ((val (apply p args))) (mutex ‘release) val)) serialized-p)))
  • 13. (define (make-mutex) (let ((cell (list false))) (define (the-mutex m) (cond ((eq? m ‘acquire) (if (test-and-set! Cell) (the-mutex ‘acquire))) (eq? m ‘release) (clear! Cell)))) the-mutex)) (define (clear! Cell) (set-car! Cell false))
  • 14. (define (test-and-set! Cell) (if (car cell) true (begin (set-car! Cell true) false)))
  • 15. 엇갈림(deadlock) • 여러 프로세스가 다른 프로세스를 지켜보 면서 아무것도 하지 못하고 끝없이 기다려 야 하는 상태. • 공유자원에 번호를 매겨놓고 차례대로 쓰 는 기법 • 엇갈림 벗어나기 기법(deadlock-recovery)
  • 16. 동기점 맞추기(barrier synchronization) • 여러 병행 프로세스가 실행되는 중에 동기 를 맞추어야 할 어떤 지점에 다다르면, 모 든 프로세스가 같은 지점에 이를때까지 멈 춤.
  • 17. Referance • 컴퓨터 프로그램의 구조와 해석 2/E – 헤럴드에빌슨, 제럴드 제이 서스먼, 줄리 서스먼 지음. 인사이트.