SlideShare a Scribd company logo
1 of 16
Download to read offline
LINUX AYGIT SURUCUSU
GELISTIRME
Dursun Can TURAN
BRAXP Bilişim Sistemleri
ONCEKI DERS NE YAPTIK
• Eşzamanlılık kavramı
• SMP, reentrancy, preemption, race condition, deadlock
• Kernelın sunduğu eşzamanlılık yapıları ve kullanımları
• Mutex, Semaphore, Spinlock
• Eşzamanlılık yapılarının alternatifleri
• Lock-free algoritmalar
• Atomic değişkenler
• seqlock
• RCU (Read-Copy-Update)
• Eşzamanlılığı sağlamak için kullanılan yöntemlerin karşılaştırılması
ASENKRONLUK NEDIR?
Asenkron Senkron
CPU VS I/O BOUND PROCESS
CPU VE I/O SCHEDULERLAR
• I/O Scheduler (Elevator)
• ATTR{queue/scheduler}="noop" ve /sys/block/<device>/queue/iosched
• noop deadline [cfq] – 2.6.18, Jens Axboe
• ionice aracı (ioprio_[get|set])
• CPU Scheduler
• Policyler: SCHED_[FIFO|RR|OTHER|BATCH|IDLE]
• Dilinlenmiş zaman (quantum)
I/O MODELLERI
• Senkron ve bloklanan
• Senkron ve bloklanmayan
• Asenkron ve bloklanan
• Asenkron ve bloklanmayan
I/O MODEL ORNEKLERI
Bloklayan Bloklamayan
Senkron read/write read/write (O_NONBLOCK)
Asenkron I/O Çoğaltma (select/poll/epoll) AIO kütüphanesi
KERNELDA ZAMAN
• HZ tanımlaması ve jiffies global değişkeni
• BogoMIPS = loops_per_jiffy x Saniyedeki jiffies sayısı x Bir işlemci döngüsünde tüketilen
instruction sayısı (milyon bazında)
• RTC üzerinden gerçek zamana erişmek
• <linux/time.h>, do_gettimeofday, mktime
• İşlemci bazında zaman ölçümü
• <asm/msr.h>, Time Stamp Counter (rdtsc, rdtscl, rdtscll)
• CONFIG_HIGH_RES_TIMERS ve nanosleep
ERTELENMİŞ İŞLEMLER
• Ertelenmiş işlemler hangi durumlarda gereklidir?
• Process context vs Interrupt context
• Busy waiting vs Sleep waiting
• Uzun ertelemeler
• cpu_relax, schedule ve timeouts
• Kısa ertelemeler
• ndelay, udelay, mdelay
• msleep, msleep_interruptible, ssleep
UZUN ERTELEMELER
• while (time_before(jiffies, j1)) cpu_relax();
• while (time_before(jiffies, j1)) schedule();
• #include <linux/wait.h>
• long wait_event_timeout(wait_queue_head_t q, condition, long timeout);
• long wait_event_interruptible_timeout(wait_queue_head_t q, condition, long timeout);
• #include <linux/sched.h>
• signed long schedule_timeout(signed long timeout);
KISA ERTELEMELER
• #include <linux/delay.h>
• void ndelay(unsigned long nsecs);
• void udelay(unsigned long usecs);
• void mdelay(unsigned long msecs);
• void msleep(unsigned int millisecs);
• unsigned long msleep_interruptible(unsigned int millisecs);
• void ssleep(unsigned int seconds);
TASKLETS
• Interrupt context
• CPU affinity
• “Soft interrupt”
• #include <linux/interrupt.h>
• struct tasklet_struct {void (*func)(unsigned long); unsigned long data;};
• void tasklet_init(struct tasklet_struct *t, void (*func)(unsigned long), unsigned long data);
• DECLARE_TASKLET(name, func, data);
• DECLARE_TASKLET_DISABLED(name, func, data);
TASKLETS
• void tasklet_disable(struct tasklet_struct *t);
• void tasklet_disable_nosync(struct tasklet_struct *t);
• void tasklet_enable(struct tasklet_struct *t);
• void tasklet_schedule(struct tasklet_struct *t);
• void tasklet_hi_schedule(struct tasklet_struct *t);
• void tasklet_kill(struct tasklet_struct *t);
WORKQUEUES
• #include <linux/workqueue.h>
• struct workqueue_struct *create_workqueue(const char *name);
• struct workqueue_struct *create_singlethread_workqueue(const char *name);
• DECLARE_WORK(name, void (*function)(void *), void *data);
• INIT_WORK(struct work_struct *work, void (*function)(void *), void *data);
• PREPARE_WORK(struct work_struct *work, void (*function)(void *), void *data);
• Paylaşımlı Kuyruk (Shared Queue)
WORKQUEUES
• int queue_work(struct workqueue_struct *queue, struct work_struct *work);
• int queue_delayed_work(struct workqueue_struct *queue, struct work_struct
*work, unsigned long delay);
• int cancel_delayed_work(struct work_struct *work);
• void flush_workqueue(struct workqueue_struct *queue);
• void destroy_workqueue(struct workqueue_struct *queue);
ÖNÜMÜZDEKİ DERS
• ioctl konvensiyonları
• İzinler (Capabilities) ve Sınırlandırma
• ioctl hariç aygıt kontrol yöntemleri
• Poll ve select
• Asenkron I/O
• Seek etme
• Erişim Kontrolü

More Related Content

Featured

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
 
Introduction to C Programming Language
Introduction to C Programming LanguageIntroduction to C Programming Language
Introduction to C Programming LanguageSimplilearn
 

Featured (20)

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
 
Introduction to C Programming Language
Introduction to C Programming LanguageIntroduction to C Programming Language
Introduction to C Programming Language
 

Linux Sürücü Geliştirme - 07 Asenkronluk ve Zamanlama

  • 1. LINUX AYGIT SURUCUSU GELISTIRME Dursun Can TURAN BRAXP Bilişim Sistemleri
  • 2. ONCEKI DERS NE YAPTIK • Eşzamanlılık kavramı • SMP, reentrancy, preemption, race condition, deadlock • Kernelın sunduğu eşzamanlılık yapıları ve kullanımları • Mutex, Semaphore, Spinlock • Eşzamanlılık yapılarının alternatifleri • Lock-free algoritmalar • Atomic değişkenler • seqlock • RCU (Read-Copy-Update) • Eşzamanlılığı sağlamak için kullanılan yöntemlerin karşılaştırılması
  • 4. CPU VS I/O BOUND PROCESS
  • 5. CPU VE I/O SCHEDULERLAR • I/O Scheduler (Elevator) • ATTR{queue/scheduler}="noop" ve /sys/block/<device>/queue/iosched • noop deadline [cfq] – 2.6.18, Jens Axboe • ionice aracı (ioprio_[get|set]) • CPU Scheduler • Policyler: SCHED_[FIFO|RR|OTHER|BATCH|IDLE] • Dilinlenmiş zaman (quantum)
  • 6. I/O MODELLERI • Senkron ve bloklanan • Senkron ve bloklanmayan • Asenkron ve bloklanan • Asenkron ve bloklanmayan
  • 7. I/O MODEL ORNEKLERI Bloklayan Bloklamayan Senkron read/write read/write (O_NONBLOCK) Asenkron I/O Çoğaltma (select/poll/epoll) AIO kütüphanesi
  • 8. KERNELDA ZAMAN • HZ tanımlaması ve jiffies global değişkeni • BogoMIPS = loops_per_jiffy x Saniyedeki jiffies sayısı x Bir işlemci döngüsünde tüketilen instruction sayısı (milyon bazında) • RTC üzerinden gerçek zamana erişmek • <linux/time.h>, do_gettimeofday, mktime • İşlemci bazında zaman ölçümü • <asm/msr.h>, Time Stamp Counter (rdtsc, rdtscl, rdtscll) • CONFIG_HIGH_RES_TIMERS ve nanosleep
  • 9. ERTELENMİŞ İŞLEMLER • Ertelenmiş işlemler hangi durumlarda gereklidir? • Process context vs Interrupt context • Busy waiting vs Sleep waiting • Uzun ertelemeler • cpu_relax, schedule ve timeouts • Kısa ertelemeler • ndelay, udelay, mdelay • msleep, msleep_interruptible, ssleep
  • 10. UZUN ERTELEMELER • while (time_before(jiffies, j1)) cpu_relax(); • while (time_before(jiffies, j1)) schedule(); • #include <linux/wait.h> • long wait_event_timeout(wait_queue_head_t q, condition, long timeout); • long wait_event_interruptible_timeout(wait_queue_head_t q, condition, long timeout); • #include <linux/sched.h> • signed long schedule_timeout(signed long timeout);
  • 11. KISA ERTELEMELER • #include <linux/delay.h> • void ndelay(unsigned long nsecs); • void udelay(unsigned long usecs); • void mdelay(unsigned long msecs); • void msleep(unsigned int millisecs); • unsigned long msleep_interruptible(unsigned int millisecs); • void ssleep(unsigned int seconds);
  • 12. TASKLETS • Interrupt context • CPU affinity • “Soft interrupt” • #include <linux/interrupt.h> • struct tasklet_struct {void (*func)(unsigned long); unsigned long data;}; • void tasklet_init(struct tasklet_struct *t, void (*func)(unsigned long), unsigned long data); • DECLARE_TASKLET(name, func, data); • DECLARE_TASKLET_DISABLED(name, func, data);
  • 13. TASKLETS • void tasklet_disable(struct tasklet_struct *t); • void tasklet_disable_nosync(struct tasklet_struct *t); • void tasklet_enable(struct tasklet_struct *t); • void tasklet_schedule(struct tasklet_struct *t); • void tasklet_hi_schedule(struct tasklet_struct *t); • void tasklet_kill(struct tasklet_struct *t);
  • 14. WORKQUEUES • #include <linux/workqueue.h> • struct workqueue_struct *create_workqueue(const char *name); • struct workqueue_struct *create_singlethread_workqueue(const char *name); • DECLARE_WORK(name, void (*function)(void *), void *data); • INIT_WORK(struct work_struct *work, void (*function)(void *), void *data); • PREPARE_WORK(struct work_struct *work, void (*function)(void *), void *data); • Paylaşımlı Kuyruk (Shared Queue)
  • 15. WORKQUEUES • int queue_work(struct workqueue_struct *queue, struct work_struct *work); • int queue_delayed_work(struct workqueue_struct *queue, struct work_struct *work, unsigned long delay); • int cancel_delayed_work(struct work_struct *work); • void flush_workqueue(struct workqueue_struct *queue); • void destroy_workqueue(struct workqueue_struct *queue);
  • 16. ÖNÜMÜZDEKİ DERS • ioctl konvensiyonları • İzinler (Capabilities) ve Sınırlandırma • ioctl hariç aygıt kontrol yöntemleri • Poll ve select • Asenkron I/O • Seek etme • Erişim Kontrolü