SlideShare a Scribd company logo
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

More Related Content

What's hot

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
Anne 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 Cloud
Pavel Odintsov
 
Linuxcon Barcelon 2012: LXC Best Practices
Linuxcon Barcelon 2012: LXC Best PracticesLinuxcon Barcelon 2012: LXC Best Practices
Linuxcon Barcelon 2012: LXC Best Practices
christophm
 
First steps on CentOs7
First steps on CentOs7First steps on CentOs7
First steps on CentOs7
Marc Cortinas Val
 
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 containers
Google
 
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
Alison Chaiken
 
Linux Interrupts
Linux InterruptsLinux Interrupts
Linux Interrupts
Kernel TLV
 
Linux cgroups and namespaces
Linux cgroups and namespacesLinux cgroups and namespaces
Linux cgroups and namespaces
Locaweb
 
Making Linux do Hard Real-time
Making Linux do Hard Real-timeMaking Linux do Hard Real-time
Making Linux do Hard Real-time
National Cheng Kung University
 
Containers with systemd-nspawn
Containers with systemd-nspawnContainers with systemd-nspawn
Containers with systemd-nspawn
Gábor Nyers
 
FreeBSD and Drivers
FreeBSD and DriversFreeBSD and Drivers
FreeBSD and Drivers
Kernel TLV
 
Systemd for developers
Systemd for developersSystemd for developers
Systemd for developers
Alison 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 Kernel
Kernel 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 systemd
David 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 - copy
Boden Russell
 
Tuning systemd for embedded
Tuning systemd for embeddedTuning systemd for embedded
Tuning systemd for embedded
Alison Chaiken
 
Linux kernel modules
Linux kernel modulesLinux kernel modules
Linux kernel modules
Eddy 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 Storage
Kernel TLV
 

What's hot (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
 

Similar to Introduction to NetBSD kernel

Chapter 6 os
Chapter 6 osChapter 6 os
Chapter 6 os
AbDul ThaYyal
 
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
Boden Russell
 
.ppt
.ppt.ppt
Walking around linux kernel
Walking around linux kernelWalking around linux kernel
Walking around linux kernel
Dharshana Kasun Warusavitharana
 
The State of Rootless Containers
The State of Rootless ContainersThe State of Rootless Containers
The State of Rootless Containers
Akihiro Suda
 
CS9222 ADVANCED OPERATING SYSTEMS
CS9222 ADVANCED OPERATING SYSTEMSCS9222 ADVANCED OPERATING SYSTEMS
CS9222 ADVANCED OPERATING SYSTEMS
Kathirvel Ayyaswamy
 
Topic 4- processes.pptx
Topic 4- processes.pptxTopic 4- processes.pptx
Topic 4- processes.pptx
DanishMahmood23
 
Clustering
ClusteringClustering
Clustering
Abhay Pai
 
Introduction To Linux Kernel Modules
Introduction To Linux Kernel ModulesIntroduction To Linux Kernel Modules
Introduction To Linux Kernel Modules
dibyajyotig
 
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
yang
 
Oct2009
Oct2009Oct2009
Oct2009
guest81ab2b4
 
Ap 06 4_10_simek
Ap 06 4_10_simekAp 06 4_10_simek
Ap 06 4_10_simek
Nguyen Vinh
 
Studienarb linux kernel-dev
Studienarb linux kernel-devStudienarb linux kernel-dev
Studienarb linux kernel-dev
murali_purushothaman
 
Lightweight Virtualization in Linux
Lightweight Virtualization in LinuxLightweight Virtualization in Linux
Lightweight Virtualization in Linux
Sadegh Dorri N.
 
linux device driver
linux device driverlinux device driver
linux device driver
Rahul Batra
 
Linux Device Driver,LDD,
Linux Device Driver,LDD,Linux Device Driver,LDD,
Linux Device Driver,LDD,
Rahul 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 storage
MayaData Inc
 
2337610
23376102337610
2337610
hantfhan
 
Introduction to OS LEVEL Virtualization & Containers
Introduction to OS LEVEL Virtualization & ContainersIntroduction to OS LEVEL Virtualization & Containers
Introduction to OS LEVEL Virtualization & Containers
Vaibhav Sharma
 
Linux scheduling and input and output
Linux scheduling and input and outputLinux scheduling and input and output
Linux scheduling and input and output
Sanidhya Chugh
 

Similar to Introduction to NetBSD kernel (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
 
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
 
Oct2009
Oct2009Oct2009
Oct2009
 
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
linux device driverlinux device driver
linux device driver
 
Linux Device Driver,LDD,
Linux Device Driver,LDD,Linux Device Driver,LDD,
Linux Device Driver,LDD,
 
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
 

Recently uploaded

20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website
Pixlogix Infotech
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
Edge AI and Vision Alliance
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
DianaGray10
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
innovationoecd
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
Adtran
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
danishmna97
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
SOFTTECHHUB
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
Neo4j
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Malak Abu Hammad
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
Neo4j
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
Kumud Singh
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
Matthew Sinclair
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
名前 です男
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
Matthew Sinclair
 
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AIEnchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Vladimir Iglovikov, Ph.D.
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 

Recently uploaded (20)

20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
 
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AIEnchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 

Introduction to NetBSD kernel

  • 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