SlideShare ist ein Scribd-Unternehmen logo
1 von 20
Downloaden Sie, um offline zu lesen
Introduction to the NetBSD kernel




Mahendra M
Mahendra_M@infosys.com
http://www.infosys.com


This work is licensed under a Creative Commons License
http://creativecommons.org/licenses/by-sa/2.5/
Agenda
   A short introduction to NetBSD systems and some history
   Suitability for embedded systems
   Slight comparisons to Linux interspersed throughout – for
    better understanding
   A look into various features
   NetBSD Capabilities !!
   Our focus will primarily be on NetBSD 2.0 series ( 3.0 was
    released a few weeks back )
About NetBSD
   A BSD “ distribution” targeted at portability.
   Includes a kernel, libraries, config tools, scripts and build
    systems.
     –   The BSD systems have had a history of around 25 years.
     –   Is under a BSD license.
   OpenBSD was forked out of the NetBSD project.
   Not really meant for Desktop/Server purposes.
NetBSD – the basic stuff
   Currently in version 3.0 ( released a few weeks back )
   Highly portable – ports exist for a large number of
    architectures and reference boards.
    –   Portability has been a design goal right from the beginning
   POSIX compliant
   Good VM, Networking, Threading subsystem
   Has withstood the test of time in the market
   Not as rapid a development model as Linux.
    –   Tends to let features stabilize on FreeBSD/OpenBSD and then
        pick it up :-)
   Some good design decisions inside the kernel.
   Low memory footprint.
Process Scheduling
   Time-sharing scheduler - based on multi-level feedback
    queues
   Each task is placed in a priority based run-queue
   Each priority is time-sliced and scheduled in round-robin
    fashion
   O(1) algorithm similar to Linux ( though not feature rich )
   Has an interactivity estimation algorithm that recalculates a
    process' priority
   Kernel pre-emption is not available
   No per-CPU runqueues
   No soft real time support available
    –   Commercial patches available for hard real time.
Approximate representation of scheduling.


RunQueue
             sched_qs[]

                      Doubly linked lists of tasks
         Running
                       Task 1   Task 2   ...      Task N   [Priority:   1]

                                                                ...
           Sleep       Task 1   Task 2   Task M            [Priority:   n]

   hardclock() - Increments CPU utilization count per tick
   schedcpu() - adjusts CPU utilization once per second and
    on 4 ticks invokes resetpriority() to recalculate a process'
    priority. Also increments sleep count of blocked processes
   resetpriority() also checks for ready higher priority
    processes and schedules a context switch
Manipulating runqueue
   void setrunqueue ( struct proc *p )
    –   set the specified process in the system run queue.
   void remrunqueue ( struct proc *p )
    –   remove the process from the run queue
   ( struct proc * ) nextrunqueue( void )
    –   Returns the next process in run queue which can run.
   The above functions have to be called with the lock held on
    the scheduler using SCHED_LOCK()
   More functions available for controlling system scheduling
    priority levels.
SMP Support and re-entrancy
   SMP Support
    –   Not really critical in embedded systems – but is very highly
        important in upcoming Telecom architectures which use multi-
        core CPUs etc.
    –   Currently being worked upon in NetBSD.
   Still has a big (BAD) global kernel lock.
   Discussion going on in lock free data structures in NetBSD.
    –   They can't implement methods like RCU
   Other general locking semantics available in the NetBSD
    kernel – slightly different in behaviour than Linux methods.
Lock Semantics
   Simplelock – simple spinning mutex – for short critical
    sections of code ( SCHED_LOCK )
    –   Only lock that can be used inside an interrupt handler.
        ( Interrupt disabling/enables has to be done manually )
    –   ( struct simplelock )
   Higher level lock for sleep/spinning is also available.
    –   Provides exclusive and shared access locks.
    –   Provides recursive exclusive access locks within a thread.
    –   Allows upgrading/downgrading of shared access locks to
        exclusive locks and vice-versa.
    –   ( struct lock )
    –   lockinit() and lockmgr() functions used
    –   spinlockinit() and spinlockmgr()
Threading model
   NetBSD kernel is thread aware and are POSIX compliant
   Supports a n:m model of threads using Scheduler
    Activations
   Drastically different from Linux's approach.
    –   Supports 1:1 model of threading ( NPTL )
    –   The kernel does not distinguish between threads and
        processes
    –   A process is a group of thread ids – thats it.
    –   All threads in a process are visible as tasks to the kernel and
        active threads are allocated time-slices for scheduling.
    –   All active threads will get their time-slices
    –   Can set real time priorities to tasks.
    –   APIs are available for real time threads handling
Threading model ( contd .. )
   NetBSD
    –   Treats threads (lwp) and processes differently
    –   Supports Scheduler Activations.
            m:n model of threading
    –   Not all threads are visible to the kernel scheduler. User space
        code takes part in telling the kernel which thread to schedule.
    –   The threads in a process have co-operative scheduling.
            A thread can keep running for most of the time – careful
             programing required.
    –   Using special environment variables Round robin scheduling
        can be achieved.
   Note : Today, Linux seems to have better thread/process
    creation, spawning and context switching times.
Threading model ( contd.. )
KQueue : Event notification mechanism
   NetBSD supports a generic event notification framework –
    kqueues.
   Excellent replacement for select() / poll() APIs.
    –   No need to pass entire descriptor set to each call.
    –   On return, applications need not check all file descriptors for
        updates.
    –   Reduces data copying ( fd list from kernel to user space and
        vice-versa )
   Can handle multiple types of events.
    –   Signals, Vnode/Process monitoring, Timer events etc.
   Can club multiple occurrences of an event into a single event
   New event types can be easily added.
   All with just two system calls !!
Debugging support and bootup
   NetBSD has much better debugging support.
    –   DDB – an in-kernel debugger
    –   Supports kernel crash dumps
            Dumps to swap partition on crash
            On reboot, retrieves the dump from swap to a specified location.
    –   Supports KGDB (source level debug) – remote debugging.
   Boot up.
    –   Doesn't support a self-extracting kernel
    –   The kernel is gzipped and given to the bootloader, which
        extracts it to memory and jumps to the start address.
    –   It can be easily added, if required.
Device support
   Support is poor in NetBSD
   Flash devices ( MTD etc. ) are poorly supported.
   Supports a primitive mechanism of Ram disk ( MFS )
    –   Not memory efficient : tmpfs is being worked upon
    –   OpenSource implementations are not available. ( Commercial
        products are available )
    –   Results in considerable lead time in development.
   For boot time, it allows embedding a file-system into the
    kernel
Build systems and configuration
   Integrated build system.
    –   The entire system : kernel, compilers and tools, libraries and
        applications can be compiled ( native or cross platform ) using
        a single script – build.sh
    –   The same script can build distributions, tarballs, archives and
        can also update existing systems and install fresh systems.
    –   Adding new components to the build framework is extremely
        easy.
   NetBSD provides an autoconf mechanism
    –   Builds a device tree format which is extremely easy for getting
        coded in and for device identification.
Some key aspects..
   Very clean code. No warnings and errors during compilation
   Little support for loadable kernel modules – not
    recommended.
   Development models is more “ cathedral” like !!
   Well documented but not easy to find answers.
   Commercial support is available.
   Many people do not contribute code changes back to the
    NetBSD tree. ( BSD License ).
   Supports non-executable stack and heap ( on architectures
    that support this )
   Has support for Xen ( not really necessary for embedded
    box but can be used for development boxes ).
Business related
   License (violation) is a serious cause of concern
    –   BSD License is very liberal
    –   One of the main reasons why telecom companies go for BSD
        – eg: Juniper ( JUNOS )
   Protocol stacks and third party code
    –   Are available usually for most BSDs.
    –   To be more portable, they tend to ignore benefits of one OS
            Eg : Making use of kqueue().
   New device support
    –   Vendors of new devices like Network Processors, etc. release
        code only/mainly for Linux ( kernel modules etc. ).
    –   Extra effort is required in such cases to port things to NetBSD.
Links
   Coming soon !!
Finally ...
   Questions ??
   Thanks to
    –   Organizers for giving me a chance to speak at GNUnify 2006
    –   NetBSD and Linux developers who helped me during my work
    –   To Infosys for sponsoring my visit to GNUnify 2006
   Special thanks to YOU for listening...


                      You can contact me at :
                    Mahendra_M@infosys.com

Weitere ähnliche Inhalte

Was ist angesagt?

Kernel Recipes 2015 - So you want to write a Linux driver framework
Kernel Recipes 2015 - So you want to write a Linux driver frameworkKernel Recipes 2015 - So you want to write a Linux driver framework
Kernel Recipes 2015 - So you want to write a Linux driver frameworkAnne Nicolas
 
Containers are the future of the Cloud
Containers are the future of the CloudContainers are the future of the Cloud
Containers are the future of the CloudPavel Odintsov
 
Linuxcon Barcelon 2012: LXC Best Practices
Linuxcon Barcelon 2012: LXC Best PracticesLinuxcon Barcelon 2012: LXC Best Practices
Linuxcon Barcelon 2012: LXC Best Practiceschristophm
 
Realizing Linux Containers (LXC)
Realizing Linux Containers (LXC)Realizing Linux Containers (LXC)
Realizing Linux Containers (LXC)Boden Russell
 
Introduction to linux containers
Introduction to linux containersIntroduction to linux containers
Introduction to linux containersGoogle
 
Systemd: the modern Linux init system you will learn to love
Systemd: the modern Linux init system you will learn to loveSystemd: the modern Linux init system you will learn to love
Systemd: the modern Linux init system you will learn to loveAlison Chaiken
 
Linux Interrupts
Linux InterruptsLinux Interrupts
Linux InterruptsKernel TLV
 
Linux cgroups and namespaces
Linux cgroups and namespacesLinux cgroups and namespaces
Linux cgroups and namespacesLocaweb
 
Containers with systemd-nspawn
Containers with systemd-nspawnContainers with systemd-nspawn
Containers with systemd-nspawnGábor Nyers
 
FreeBSD and Drivers
FreeBSD and DriversFreeBSD and Drivers
FreeBSD and DriversKernel TLV
 
Systemd for developers
Systemd for developersSystemd for developers
Systemd for developersAlison Chaiken
 
High Performance Storage Devices in the Linux Kernel
High Performance Storage Devices in the Linux KernelHigh Performance Storage Devices in the Linux Kernel
High Performance Storage Devices in the Linux KernelKernel TLV
 
Effective service and resource management with systemd
Effective service and resource management with systemdEffective service and resource management with systemd
Effective service and resource management with systemdDavid Timothy Strauss
 
Linux container, namespaces & CGroup.
Linux container, namespaces & CGroup. Linux container, namespaces & CGroup.
Linux container, namespaces & CGroup. Neeraj Shrimali
 
Linux containers – next gen virtualization for cloud (atl summit) ar4 3 - copy
Linux containers – next gen virtualization for cloud (atl summit) ar4 3 - copyLinux containers – next gen virtualization for cloud (atl summit) ar4 3 - copy
Linux containers – next gen virtualization for cloud (atl summit) ar4 3 - copyBoden Russell
 
Tuning systemd for embedded
Tuning systemd for embeddedTuning systemd for embedded
Tuning systemd for embeddedAlison Chaiken
 
Linux kernel modules
Linux kernel modulesLinux kernel modules
Linux kernel modulesEddy Reyes
 
The Linux Block Layer - Built for Fast Storage
The Linux Block Layer - Built for Fast StorageThe Linux Block Layer - Built for Fast Storage
The Linux Block Layer - Built for Fast StorageKernel TLV
 

Was ist angesagt? (20)

Kernel Recipes 2015 - So you want to write a Linux driver framework
Kernel Recipes 2015 - So you want to write a Linux driver frameworkKernel Recipes 2015 - So you want to write a Linux driver framework
Kernel Recipes 2015 - So you want to write a Linux driver framework
 
Containers are the future of the Cloud
Containers are the future of the CloudContainers are the future of the Cloud
Containers are the future of the Cloud
 
Linuxcon Barcelon 2012: LXC Best Practices
Linuxcon Barcelon 2012: LXC Best PracticesLinuxcon Barcelon 2012: LXC Best Practices
Linuxcon Barcelon 2012: LXC Best Practices
 
First steps on CentOs7
First steps on CentOs7First steps on CentOs7
First steps on CentOs7
 
Realizing Linux Containers (LXC)
Realizing Linux Containers (LXC)Realizing Linux Containers (LXC)
Realizing Linux Containers (LXC)
 
Introduction to linux containers
Introduction to linux containersIntroduction to linux containers
Introduction to linux containers
 
Systemd: the modern Linux init system you will learn to love
Systemd: the modern Linux init system you will learn to loveSystemd: the modern Linux init system you will learn to love
Systemd: the modern Linux init system you will learn to love
 
Linux Interrupts
Linux InterruptsLinux Interrupts
Linux Interrupts
 
Linux cgroups and namespaces
Linux cgroups and namespacesLinux cgroups and namespaces
Linux cgroups and namespaces
 
Making Linux do Hard Real-time
Making Linux do Hard Real-timeMaking Linux do Hard Real-time
Making Linux do Hard Real-time
 
Containers with systemd-nspawn
Containers with systemd-nspawnContainers with systemd-nspawn
Containers with systemd-nspawn
 
FreeBSD and Drivers
FreeBSD and DriversFreeBSD and Drivers
FreeBSD and Drivers
 
Systemd for developers
Systemd for developersSystemd for developers
Systemd for developers
 
High Performance Storage Devices in the Linux Kernel
High Performance Storage Devices in the Linux KernelHigh Performance Storage Devices in the Linux Kernel
High Performance Storage Devices in the Linux Kernel
 
Effective service and resource management with systemd
Effective service and resource management with systemdEffective service and resource management with systemd
Effective service and resource management with systemd
 
Linux container, namespaces & CGroup.
Linux container, namespaces & CGroup. Linux container, namespaces & CGroup.
Linux container, namespaces & CGroup.
 
Linux containers – next gen virtualization for cloud (atl summit) ar4 3 - copy
Linux containers – next gen virtualization for cloud (atl summit) ar4 3 - copyLinux containers – next gen virtualization for cloud (atl summit) ar4 3 - copy
Linux containers – next gen virtualization for cloud (atl summit) ar4 3 - copy
 
Tuning systemd for embedded
Tuning systemd for embeddedTuning systemd for embedded
Tuning systemd for embedded
 
Linux kernel modules
Linux kernel modulesLinux kernel modules
Linux kernel modules
 
The Linux Block Layer - Built for Fast Storage
The Linux Block Layer - Built for Fast StorageThe Linux Block Layer - Built for Fast Storage
The Linux Block Layer - Built for Fast Storage
 

Ähnlich wie Introduction to the NetBSD Kernel Under 40 Characters

Linux Container Brief for IEEE WG P2302
Linux Container Brief for IEEE WG P2302Linux Container Brief for IEEE WG P2302
Linux Container Brief for IEEE WG P2302Boden Russell
 
The State of Rootless Containers
The State of Rootless ContainersThe State of Rootless Containers
The State of Rootless ContainersAkihiro Suda
 
CS9222 ADVANCED OPERATING SYSTEMS
CS9222 ADVANCED OPERATING SYSTEMSCS9222 ADVANCED OPERATING SYSTEMS
CS9222 ADVANCED OPERATING SYSTEMSKathirvel Ayyaswamy
 
Introduction To Linux Kernel Modules
Introduction To Linux Kernel ModulesIntroduction To Linux Kernel Modules
Introduction To Linux Kernel Modulesdibyajyotig
 
Evolution of the Windows Kernel Architecture, by Dave Probert
Evolution of the Windows Kernel Architecture, by Dave ProbertEvolution of the Windows Kernel Architecture, by Dave Probert
Evolution of the Windows Kernel Architecture, by Dave Probertyang
 
Ap 06 4_10_simek
Ap 06 4_10_simekAp 06 4_10_simek
Ap 06 4_10_simekNguyen Vinh
 
Lightweight Virtualization in Linux
Lightweight Virtualization in LinuxLightweight Virtualization in Linux
Lightweight Virtualization in LinuxSadegh Dorri N.
 
Linux Device Driver,LDD,
Linux Device Driver,LDD,Linux Device Driver,LDD,
Linux Device Driver,LDD,Rahul Batra
 
linux device driver
linux device driverlinux device driver
linux device driverRahul Batra
 
Webinar: OpenEBS - Still Free and now FASTEST Kubernetes storage
Webinar: OpenEBS - Still Free and now FASTEST Kubernetes storageWebinar: OpenEBS - Still Free and now FASTEST Kubernetes storage
Webinar: OpenEBS - Still Free and now FASTEST Kubernetes storageMayaData Inc
 
Introduction to OS LEVEL Virtualization & Containers
Introduction to OS LEVEL Virtualization & ContainersIntroduction to OS LEVEL Virtualization & Containers
Introduction to OS LEVEL Virtualization & ContainersVaibhav Sharma
 
Linux scheduling and input and output
Linux scheduling and input and outputLinux scheduling and input and output
Linux scheduling and input and outputSanidhya Chugh
 

Ähnlich wie Introduction to the NetBSD Kernel Under 40 Characters (20)

Chapter 6 os
Chapter 6 osChapter 6 os
Chapter 6 os
 
Linux Container Brief for IEEE WG P2302
Linux Container Brief for IEEE WG P2302Linux Container Brief for IEEE WG P2302
Linux Container Brief for IEEE WG P2302
 
.ppt
.ppt.ppt
.ppt
 
Walking around linux kernel
Walking around linux kernelWalking around linux kernel
Walking around linux kernel
 
The State of Rootless Containers
The State of Rootless ContainersThe State of Rootless Containers
The State of Rootless Containers
 
CS9222 ADVANCED OPERATING SYSTEMS
CS9222 ADVANCED OPERATING SYSTEMSCS9222 ADVANCED OPERATING SYSTEMS
CS9222 ADVANCED OPERATING SYSTEMS
 
Topic 4- processes.pptx
Topic 4- processes.pptxTopic 4- processes.pptx
Topic 4- processes.pptx
 
Clustering
ClusteringClustering
Clustering
 
Introduction To Linux Kernel Modules
Introduction To Linux Kernel ModulesIntroduction To Linux Kernel Modules
Introduction To Linux Kernel Modules
 
Oct2009
Oct2009Oct2009
Oct2009
 
Evolution of the Windows Kernel Architecture, by Dave Probert
Evolution of the Windows Kernel Architecture, by Dave ProbertEvolution of the Windows Kernel Architecture, by Dave Probert
Evolution of the Windows Kernel Architecture, by Dave Probert
 
Ap 06 4_10_simek
Ap 06 4_10_simekAp 06 4_10_simek
Ap 06 4_10_simek
 
Studienarb linux kernel-dev
Studienarb linux kernel-devStudienarb linux kernel-dev
Studienarb linux kernel-dev
 
Lightweight Virtualization in Linux
Lightweight Virtualization in LinuxLightweight Virtualization in Linux
Lightweight Virtualization in Linux
 
Linux Device Driver,LDD,
Linux Device Driver,LDD,Linux Device Driver,LDD,
Linux Device Driver,LDD,
 
linux device driver
linux device driverlinux device driver
linux device driver
 
Webinar: OpenEBS - Still Free and now FASTEST Kubernetes storage
Webinar: OpenEBS - Still Free and now FASTEST Kubernetes storageWebinar: OpenEBS - Still Free and now FASTEST Kubernetes storage
Webinar: OpenEBS - Still Free and now FASTEST Kubernetes storage
 
2337610
23376102337610
2337610
 
Introduction to OS LEVEL Virtualization & Containers
Introduction to OS LEVEL Virtualization & ContainersIntroduction to OS LEVEL Virtualization & Containers
Introduction to OS LEVEL Virtualization & Containers
 
Linux scheduling and input and output
Linux scheduling and input and outputLinux scheduling and input and output
Linux scheduling and input and output
 

Kürzlich hochgeladen

[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 

Kürzlich hochgeladen (20)

[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 

Introduction to the NetBSD Kernel Under 40 Characters

  • 1. Introduction to the NetBSD kernel Mahendra M Mahendra_M@infosys.com http://www.infosys.com This work is licensed under a Creative Commons License http://creativecommons.org/licenses/by-sa/2.5/
  • 2. Agenda  A short introduction to NetBSD systems and some history  Suitability for embedded systems  Slight comparisons to Linux interspersed throughout – for better understanding  A look into various features  NetBSD Capabilities !!  Our focus will primarily be on NetBSD 2.0 series ( 3.0 was released a few weeks back )
  • 3. About NetBSD  A BSD “ distribution” targeted at portability.  Includes a kernel, libraries, config tools, scripts and build systems. – The BSD systems have had a history of around 25 years. – Is under a BSD license.  OpenBSD was forked out of the NetBSD project.  Not really meant for Desktop/Server purposes.
  • 4. NetBSD – the basic stuff  Currently in version 3.0 ( released a few weeks back )  Highly portable – ports exist for a large number of architectures and reference boards. – Portability has been a design goal right from the beginning  POSIX compliant  Good VM, Networking, Threading subsystem  Has withstood the test of time in the market  Not as rapid a development model as Linux. – Tends to let features stabilize on FreeBSD/OpenBSD and then pick it up :-)  Some good design decisions inside the kernel.  Low memory footprint.
  • 5. Process Scheduling  Time-sharing scheduler - based on multi-level feedback queues  Each task is placed in a priority based run-queue  Each priority is time-sliced and scheduled in round-robin fashion  O(1) algorithm similar to Linux ( though not feature rich )  Has an interactivity estimation algorithm that recalculates a process' priority  Kernel pre-emption is not available  No per-CPU runqueues  No soft real time support available – Commercial patches available for hard real time.
  • 6. Approximate representation of scheduling. RunQueue sched_qs[] Doubly linked lists of tasks Running Task 1 Task 2 ... Task N [Priority: 1] ... Sleep Task 1 Task 2 Task M [Priority: n]  hardclock() - Increments CPU utilization count per tick  schedcpu() - adjusts CPU utilization once per second and on 4 ticks invokes resetpriority() to recalculate a process' priority. Also increments sleep count of blocked processes  resetpriority() also checks for ready higher priority processes and schedules a context switch
  • 7. Manipulating runqueue  void setrunqueue ( struct proc *p ) – set the specified process in the system run queue.  void remrunqueue ( struct proc *p ) – remove the process from the run queue  ( struct proc * ) nextrunqueue( void ) – Returns the next process in run queue which can run.  The above functions have to be called with the lock held on the scheduler using SCHED_LOCK()  More functions available for controlling system scheduling priority levels.
  • 8. SMP Support and re-entrancy  SMP Support – Not really critical in embedded systems – but is very highly important in upcoming Telecom architectures which use multi- core CPUs etc. – Currently being worked upon in NetBSD.  Still has a big (BAD) global kernel lock.  Discussion going on in lock free data structures in NetBSD. – They can't implement methods like RCU  Other general locking semantics available in the NetBSD kernel – slightly different in behaviour than Linux methods.
  • 9. Lock Semantics  Simplelock – simple spinning mutex – for short critical sections of code ( SCHED_LOCK ) – Only lock that can be used inside an interrupt handler. ( Interrupt disabling/enables has to be done manually ) – ( struct simplelock )  Higher level lock for sleep/spinning is also available. – Provides exclusive and shared access locks. – Provides recursive exclusive access locks within a thread. – Allows upgrading/downgrading of shared access locks to exclusive locks and vice-versa. – ( struct lock ) – lockinit() and lockmgr() functions used – spinlockinit() and spinlockmgr()
  • 10. Threading model  NetBSD kernel is thread aware and are POSIX compliant  Supports a n:m model of threads using Scheduler Activations  Drastically different from Linux's approach. – Supports 1:1 model of threading ( NPTL ) – The kernel does not distinguish between threads and processes – A process is a group of thread ids – thats it. – All threads in a process are visible as tasks to the kernel and active threads are allocated time-slices for scheduling. – All active threads will get their time-slices – Can set real time priorities to tasks. – APIs are available for real time threads handling
  • 11. Threading model ( contd .. )  NetBSD – Treats threads (lwp) and processes differently – Supports Scheduler Activations.  m:n model of threading – Not all threads are visible to the kernel scheduler. User space code takes part in telling the kernel which thread to schedule. – The threads in a process have co-operative scheduling.  A thread can keep running for most of the time – careful programing required. – Using special environment variables Round robin scheduling can be achieved.  Note : Today, Linux seems to have better thread/process creation, spawning and context switching times.
  • 12. Threading model ( contd.. )
  • 13. KQueue : Event notification mechanism  NetBSD supports a generic event notification framework – kqueues.  Excellent replacement for select() / poll() APIs. – No need to pass entire descriptor set to each call. – On return, applications need not check all file descriptors for updates. – Reduces data copying ( fd list from kernel to user space and vice-versa )  Can handle multiple types of events. – Signals, Vnode/Process monitoring, Timer events etc.  Can club multiple occurrences of an event into a single event  New event types can be easily added.  All with just two system calls !!
  • 14. Debugging support and bootup  NetBSD has much better debugging support. – DDB – an in-kernel debugger – Supports kernel crash dumps  Dumps to swap partition on crash  On reboot, retrieves the dump from swap to a specified location. – Supports KGDB (source level debug) – remote debugging.  Boot up. – Doesn't support a self-extracting kernel – The kernel is gzipped and given to the bootloader, which extracts it to memory and jumps to the start address. – It can be easily added, if required.
  • 15. Device support  Support is poor in NetBSD  Flash devices ( MTD etc. ) are poorly supported.  Supports a primitive mechanism of Ram disk ( MFS ) – Not memory efficient : tmpfs is being worked upon – OpenSource implementations are not available. ( Commercial products are available ) – Results in considerable lead time in development.  For boot time, it allows embedding a file-system into the kernel
  • 16. Build systems and configuration  Integrated build system. – The entire system : kernel, compilers and tools, libraries and applications can be compiled ( native or cross platform ) using a single script – build.sh – The same script can build distributions, tarballs, archives and can also update existing systems and install fresh systems. – Adding new components to the build framework is extremely easy.  NetBSD provides an autoconf mechanism – Builds a device tree format which is extremely easy for getting coded in and for device identification.
  • 17. Some key aspects..  Very clean code. No warnings and errors during compilation  Little support for loadable kernel modules – not recommended.  Development models is more “ cathedral” like !!  Well documented but not easy to find answers.  Commercial support is available.  Many people do not contribute code changes back to the NetBSD tree. ( BSD License ).  Supports non-executable stack and heap ( on architectures that support this )  Has support for Xen ( not really necessary for embedded box but can be used for development boxes ).
  • 18. Business related  License (violation) is a serious cause of concern – BSD License is very liberal – One of the main reasons why telecom companies go for BSD – eg: Juniper ( JUNOS )  Protocol stacks and third party code – Are available usually for most BSDs. – To be more portable, they tend to ignore benefits of one OS  Eg : Making use of kqueue().  New device support – Vendors of new devices like Network Processors, etc. release code only/mainly for Linux ( kernel modules etc. ). – Extra effort is required in such cases to port things to NetBSD.
  • 19. Links  Coming soon !!
  • 20. Finally ...  Questions ??  Thanks to – Organizers for giving me a chance to speak at GNUnify 2006 – NetBSD and Linux developers who helped me during my work – To Infosys for sponsoring my visit to GNUnify 2006  Special thanks to YOU for listening... You can contact me at : Mahendra_M@infosys.com