SlideShare a Scribd company logo
1 of 14
Очередь запросов TWI
(кольцевой буфер)
Массив структур TWI[] после
инициализации
так он выглядит физически
так мы его себе представляем
Массив структур в SRAM
TWI[0] TWI[1] TWI[2] TWI[3] TWI[4] TWI[5] TWI[6] TWI[7]
SLA pW nW pR nR
flag = 0
Переменные head и tail
Переменная head указывает куда
можно положить данные для
следующего фрейма.
Переменная tail указывает какой
фрейм будет следующим.
Обе переменные инициализируются
0 и указывают на начало масcива.
head
tail
TWI[0] TWI[1] TWI[2] TWI[3] TWI[4] TWI[5] TWI[6] TWI[7]
get_AC1 TWI[1] TWI[2] TWI[3] TWI[4] TWI[5] TWI[6] TWI[7]
flag = 1
Выполнение функции get_AC1
Данные для этой функции
копируются в TWI[0].
Значение head увеличивается на 1,
становится равным head=1 и
указывает на следующую ячейку.
Так как head!=tail и переменная
flag=0 устанавливаем ее в 1 и даем
СТАРТ.
head
tail
get_AC1 get_AC2 TWI[2] TWI[3] TWI[4] TWI[5] TWI[6] TWI[7]
flag = 1
Выполнение функции get_AC2
Данные для этой функции
копируются в TWI[1].
Значение head увеличивается на 1,
становится равным head=2 и
указывает на следующую ячейку.
Хоть head!=tail, переменная flag=1,
поэтому СТАРТ не дается.
head
tail
get_AC1 get_AC2 get_AC3 TWI[3] TWI[4] TWI[5] TWI[6] TWI[7]
flag = 1
Выполнение функции get_AC3
Данные для этой функции
копируются в TWI[2].
Значение head увеличивается на 1,
становится равным head=3 и
указывает на следующую ячейку.
Хоть head!=tail, переменная flag=1,
поэтому СТАРТ не дается.
head
tail
get_AC1 get_AC2 get_AC3 get_AC4 TWI[4] TWI[5] TWI[6] TWI[7]
flag = 1
Выполнение функции get_AC4
Данные для этой функции
копируются в TWI[3].
Значение head увеличивается на 1,
становится равным head=4 и
указывает на следующую ячейку.
Хоть head!=tail, переменная flag=1,
поэтому СТАРТ не дается.
head
tail
get_AC1 get_AC2 get_AC3 get_AC4 get_AC5 TWI[5] TWI[6] TWI[7]
flag = 1
Выполнение функции get_AC5
Данные для этой функции
копируются в TWI[4].
Значение head увеличивается на 1,
становится равным head=5 и
указывает на следующую ячейку.
Хоть head!=tail, переменная flag=1,
поэтому СТАРТ не дается.
Предположим в этот момент
функция get_AC1 полностью
отработана. Обработчик видит что
head!=tail, увеличивает tail на 1 и
дает СТОП-СТАРТ. Таким образом
обработчик сразу же начинает
отрабатывать get_AC2.
head
tail
get_AC1 get_AC2 get_AC3 get_AC4 get_AC5 get_AC6 TWI[6] TWI[7]
flag = 1
Выполнение функции get_AC6
Данные для этой функции
копируются в TWI[5].
Значение head увеличивается на 1,
становится равным head=6 и
указывает на следующую ячейку.
Хоть head!=tail, переменная flag=1,
поэтому СТАРТ не дается.
head
tail
get_AC1 get_AC2 get_AC3 get_AC4 get_AC5 get_AC6 get_B0 TWI[7]
flag = 1
Выполнение функции get_B0
Данные для этой функции
копируются в TWI[6].
Значение head увеличивается на 1,
становится равным head=7 и
указывает на следующую ячейку.
Хоть head!=tail, переменная flag=1,
поэтому СТАРТ не дается.
head
tail
get_AC1 get_AC2 get_AC3 get_AC4 get_AC5 get_AC6 get_B0 get_B1
flag = 1
Выполнение функции get_B1
Данные для этой функции
копируются в TWI[7].
В этом случае head сбросится на 0 и
будет указывать на нулевую ячейку.
Хоть head!=tail, переменная flag=1,
поэтому СТАРТ не дается.
head
tail
get_AC1 get_AC2 get_AC3 get_AC4 get_AC5 get_AC6 get_B0 get_B1
flag = 1
Выполнение функции get_MB
Эта функция будет планировщиком
отброшена, так как выполняется
условие tail-head=1 || head-tail=size-1
(буфер переполнен).
СТАРТ не дается.
head
tail
get_AC1 get_AC2 get_AC3 get_AC4 get_AC5 get_AC6 get_B0 get_B1
flag = 1
Выполнение функции get_MC
Эта функция будет планировщиком
отброшена, так как выполняется
условие tail-head=1 || head-tail=size-1
(буфер переполнен).
СТАРТ не дается.
Предположим в этот момент
функция get_AC2 полностью
отработана. Обработчик видит что
head!=tail, увеличивает tail на 1 и
дает СТОП-СТАРТ. Таким образом
обработчик сразу же начинает
отрабатывать get_AC3.
head
tail
get_MD get_AC2 get_AC3 get_AC4 get_AC5 get_AC6 get_B0 get_B1
flag = 1
Выполнение функции get_MD
Данные для этой функции
копируются в TWI[0].
Значение head увеличивается на 1,
становится равным head=1 и
указывает на следующую ячейку.
Хоть head!=tail, переменная flag=1,
поэтому СТАРТ не дается.
Любая функция которая попытается
получить запрос на шину TWI будет
отброшена до тех пор пока функция
get_AC3 не будет отработана и место
в буфере не освободится.
head
tail
get_MD get_AC2 get_AC3 get_AC4 get_AC5 get_AC6 get_B0 get_B1
flag = 0
Через какое-то время
Обработчик будет отрабатывать
функцию за функцией, выплёвывая в
шину байты в заданной
последовательности. И только когда
tail догонит и станет равна head
выполнится условие буфер пуст и
вместо СТАРТ-СТОП выдастся СТОП
тем самым останавливая
обработчик. При этом flag сбросится
и станет равным 0. Как только в
буфер положатся данные, head
станет не равным tail, и так как flag=0
запустится СТАРТ и обработчик вновь
начнет отрабатывать очередь, пока
не выполнит последний элемент.
head
tail

More Related Content

Featured

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
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...DevGAMM Conference
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationErica Santiago
 
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellGood Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellSaba Software
 

Featured (20)

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...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy Presentation
 
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellGood Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
 

мьютекс для Twi

  • 1. Очередь запросов TWI (кольцевой буфер) Массив структур TWI[] после инициализации так он выглядит физически так мы его себе представляем Массив структур в SRAM TWI[0] TWI[1] TWI[2] TWI[3] TWI[4] TWI[5] TWI[6] TWI[7] SLA pW nW pR nR
  • 2. flag = 0 Переменные head и tail Переменная head указывает куда можно положить данные для следующего фрейма. Переменная tail указывает какой фрейм будет следующим. Обе переменные инициализируются 0 и указывают на начало масcива. head tail TWI[0] TWI[1] TWI[2] TWI[3] TWI[4] TWI[5] TWI[6] TWI[7]
  • 3. get_AC1 TWI[1] TWI[2] TWI[3] TWI[4] TWI[5] TWI[6] TWI[7] flag = 1 Выполнение функции get_AC1 Данные для этой функции копируются в TWI[0]. Значение head увеличивается на 1, становится равным head=1 и указывает на следующую ячейку. Так как head!=tail и переменная flag=0 устанавливаем ее в 1 и даем СТАРТ. head tail
  • 4. get_AC1 get_AC2 TWI[2] TWI[3] TWI[4] TWI[5] TWI[6] TWI[7] flag = 1 Выполнение функции get_AC2 Данные для этой функции копируются в TWI[1]. Значение head увеличивается на 1, становится равным head=2 и указывает на следующую ячейку. Хоть head!=tail, переменная flag=1, поэтому СТАРТ не дается. head tail
  • 5. get_AC1 get_AC2 get_AC3 TWI[3] TWI[4] TWI[5] TWI[6] TWI[7] flag = 1 Выполнение функции get_AC3 Данные для этой функции копируются в TWI[2]. Значение head увеличивается на 1, становится равным head=3 и указывает на следующую ячейку. Хоть head!=tail, переменная flag=1, поэтому СТАРТ не дается. head tail
  • 6. get_AC1 get_AC2 get_AC3 get_AC4 TWI[4] TWI[5] TWI[6] TWI[7] flag = 1 Выполнение функции get_AC4 Данные для этой функции копируются в TWI[3]. Значение head увеличивается на 1, становится равным head=4 и указывает на следующую ячейку. Хоть head!=tail, переменная flag=1, поэтому СТАРТ не дается. head tail
  • 7. get_AC1 get_AC2 get_AC3 get_AC4 get_AC5 TWI[5] TWI[6] TWI[7] flag = 1 Выполнение функции get_AC5 Данные для этой функции копируются в TWI[4]. Значение head увеличивается на 1, становится равным head=5 и указывает на следующую ячейку. Хоть head!=tail, переменная flag=1, поэтому СТАРТ не дается. Предположим в этот момент функция get_AC1 полностью отработана. Обработчик видит что head!=tail, увеличивает tail на 1 и дает СТОП-СТАРТ. Таким образом обработчик сразу же начинает отрабатывать get_AC2. head tail
  • 8. get_AC1 get_AC2 get_AC3 get_AC4 get_AC5 get_AC6 TWI[6] TWI[7] flag = 1 Выполнение функции get_AC6 Данные для этой функции копируются в TWI[5]. Значение head увеличивается на 1, становится равным head=6 и указывает на следующую ячейку. Хоть head!=tail, переменная flag=1, поэтому СТАРТ не дается. head tail
  • 9. get_AC1 get_AC2 get_AC3 get_AC4 get_AC5 get_AC6 get_B0 TWI[7] flag = 1 Выполнение функции get_B0 Данные для этой функции копируются в TWI[6]. Значение head увеличивается на 1, становится равным head=7 и указывает на следующую ячейку. Хоть head!=tail, переменная flag=1, поэтому СТАРТ не дается. head tail
  • 10. get_AC1 get_AC2 get_AC3 get_AC4 get_AC5 get_AC6 get_B0 get_B1 flag = 1 Выполнение функции get_B1 Данные для этой функции копируются в TWI[7]. В этом случае head сбросится на 0 и будет указывать на нулевую ячейку. Хоть head!=tail, переменная flag=1, поэтому СТАРТ не дается. head tail
  • 11. get_AC1 get_AC2 get_AC3 get_AC4 get_AC5 get_AC6 get_B0 get_B1 flag = 1 Выполнение функции get_MB Эта функция будет планировщиком отброшена, так как выполняется условие tail-head=1 || head-tail=size-1 (буфер переполнен). СТАРТ не дается. head tail
  • 12. get_AC1 get_AC2 get_AC3 get_AC4 get_AC5 get_AC6 get_B0 get_B1 flag = 1 Выполнение функции get_MC Эта функция будет планировщиком отброшена, так как выполняется условие tail-head=1 || head-tail=size-1 (буфер переполнен). СТАРТ не дается. Предположим в этот момент функция get_AC2 полностью отработана. Обработчик видит что head!=tail, увеличивает tail на 1 и дает СТОП-СТАРТ. Таким образом обработчик сразу же начинает отрабатывать get_AC3. head tail
  • 13. get_MD get_AC2 get_AC3 get_AC4 get_AC5 get_AC6 get_B0 get_B1 flag = 1 Выполнение функции get_MD Данные для этой функции копируются в TWI[0]. Значение head увеличивается на 1, становится равным head=1 и указывает на следующую ячейку. Хоть head!=tail, переменная flag=1, поэтому СТАРТ не дается. Любая функция которая попытается получить запрос на шину TWI будет отброшена до тех пор пока функция get_AC3 не будет отработана и место в буфере не освободится. head tail
  • 14. get_MD get_AC2 get_AC3 get_AC4 get_AC5 get_AC6 get_B0 get_B1 flag = 0 Через какое-то время Обработчик будет отрабатывать функцию за функцией, выплёвывая в шину байты в заданной последовательности. И только когда tail догонит и станет равна head выполнится условие буфер пуст и вместо СТАРТ-СТОП выдастся СТОП тем самым останавливая обработчик. При этом flag сбросится и станет равным 0. Как только в буфер положатся данные, head станет не равным tail, и так как flag=0 запустится СТАРТ и обработчик вновь начнет отрабатывать очередь, пока не выполнит последний элемент. head tail