SlideShare una empresa de Scribd logo
1 de 20
Descargar para leer sin conexión
NetBSD and Linux for Embedded Systems




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/
About the talk

   This talk is NOT about to compare NetBSD and Linux and
    find out which is better.
    –   We shall compare – but not criticize !!
   We shall try to understand both systems in their own merit
   It is about sharing our experiences with both the systems –
    more from a embedded & telecom OS perspective.
   We hope to help you choose.
Agenda
   A short introduction to NetBSD and Linux based systems
   Suitability for embedded systems
   Introduction to the features available in NB and Linux
    –   Specifically for Embedded Systems
   Feature wise comparison of the two kernels
    –   Core architecture, Threading model, Real time capabilities,
        modularity, performance, ease of deployment, portability
   Linux capabilities.
   NetBSD Capabilities
    –   Kqueue : Event notification framework
   Availability of Code for future needs
   Feasibility and time to market along with License issues.
About the Systems
   Linux
    –   Refers only to the kernel
    –   Distributions are built around it. ( distros available for
        embedded systems )
    –   Has a history of around 15 years
    –   Is under the GPL license ( v2.0 ) and supports binary modules.
   NetBSD
    –   A BSD “ distribution” targeted at portability.
    –   Includes a kernel, libraries, config tools, scripts and build
        systems.
    –   Targeted at portability
    –   The BSD systems have had a history of around 25 years.
    –   Is under a BSD license.
Common stuff ...
   Highly portable – ports exist for a large number of
    architectures and reference boards.
   Both are POSIX compliant
   Good VM, Networking, Threading subsystems
   Both have been time tested in the market
   Active development happening
    –   Directly on Linux kernel – on multiple trees maintained by
        different people.
    –   NetBSD tend to let features stabilize on FreeBSD/OpenBSD
        and then pick it up :-)
   Let us get on with the differences....
Memory foot print
   Linux is slowly getting bloated.
    –   There are projects that are working on reducing the size of
        Linux kernel
    –   “ Linux Tiny” project provides a set of patches that can be
         applied to the Linux kernel to reduce the kernel size (built
         image and run time memory requirements)
   NetBSD projects boast of reduced kernel size.
    –   TINY configuration file is distributed along with the source.
   Both kernels can be easily reduced to a size of less than
    1MB ( uncompressed : ~900k, compressed : ~400k )
   With sufficient hacking around, it can be reduced even
    further.
Process Scheduling
   Both OS follow a similar model in running user space
    processes.
    –   Time slice based – and O(1) in nature.
    –   They have priority based levels and processes are placed on
        these levels based on their priority
    –   Both support dynamic priority modification based on
        interactiveness of a process
            Not needed for embedded systems – and can be turned off at
             compile time.
    –   Both support the same user space priorities (40)
   Linux has two run-queues : An active and an expired run-
    queue.
   Linux also has a run-queue per CPU – for SMP boxes.
Process Run-queue


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

                                                              ...
                     Task 1   Task 2   Task M            [Priority:140]

           Expired
                              ...

                      ...
           Migration Thread
                                             From kernel/sched.c
Other stuff ...
   Kernel pre-emption.
    –   Linux kernel supports kernel pre-emption, but only at pre-
        emptible points inside in the kernel.
    –   There are still areas within the kernel which cannot be pre-
        empted.
    –   NetBSD does not support kernel pre-emption.
            Hence real-time support is pretty poor on NetBSD systems
   SMP Support ( not really critical in embedded systems )
    –   Very good in Linux.
    –   Worked upon in NetBSD.
Real-time performance
   Hard real-time performance
    –   Not available in both kernels by default.
    –   FSM labs provides patches to the Linux kernel ( under GPL )
        and commercial patches to NetBSD.
            Works by running Linux/NetBSD kernel as low priority tasks
             under a real time kernel.
   Soft real-time performance.
    –   Linux is pretty good in providing soft real time facilities.
    –   In addition to the 40 user land priorities, Linux provides an
        additional 100 real-time priorities
    –   Linux supports two soft real time scheduling options
            SCHED_FIFO – First in first out
            SCHED_RR – Round robin
    –   Real time tasks cannot be pre-empted.
Threading models
   Both kernels are thread aware and are POSIX compliant
   They support different threading models
    –   This is where the difference starts and things get interesting..
   Linux
    –   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 models ( 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.
   Both groups had debated the models before taking up their
    approaches. Both methods are “ claimed” to be better than
    the other.
   Today, Linux seems to have better thread/process creation,
    spawning and context switching times.
Debugging support
   NetBSD has much better debugging support.
    –   DDB – an in-kernel debugger
    –   Supports kernel crash dumps
    –   Supports KGDB (source level debug) – remote debugging.
   Linux
    –   Patches available for crash dumps and KDB & KGDB (not
        available for all architectures)
    –   Linux Trace Toolkit, UML etc. are also available methods.
    –   Has “ Kernel Hacking” Option in kernel configuration
            Allows debugging using “ Magic SysRQs” , Debugging of actions
             like memory allocations, file systems, highmem, stack overflows,
             page allocations etc.
            Also allows stats collection for some modules.
    –   Also, early printk() support is pretty recent.
Flash Devices and File Systems
   Support is poor in NetBSD
   Linux supports
    –   Advanced MTD support ( device concatenation, FTL, NFTL )
    –   JFFS2 ( JFFS3 is being worked on )
    –   RAM file systems and ramdisk support
    –   Supports initrd
   In NetBSD
    –   OpenSource implementations of the above are not available.
        ( Commercial products are available )
    –   Results in considerable lead time in development.
    –   Supports MFS ( not memory efficient ) : tmpfs is being worked
        upon
    –   For boot time, it allows embedding a file-system into the kernel
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 !!
Build systems and configuration
   NetBSD is better
    –   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.
   Linux – Such systems exist but it is not as flexible as BSD
   Both NetBSD and Linux provide different configuration
    mechanisms.
    –   NetBSD builds a device tree format.
    –   Linux provides a GUI interface for configuring the kernel...
Other differences.
   Linux kernel code throws out lot of warnings during
    compilation. NetBSD is very clean in this aspect.
   Linux supports MMU Less operations.
   Loadable kernel modules
    –   Better supported in Linux.
   Better device support in Linux
   With 2.6 kernel, the device driver model has vastly improved
    ( attend other talks at FOSS.in for more details )
   Portability has been a design goal for NetBSD.
   Development models are vastly different :-)
    –   NetBSD is more “ cathedral” like !!
   In Linux, you get answers easily :-)
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 and Linux.
    –   To be more portable, they tend to ignore benefits of one OS
   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.
   In case of Linux, extra time is required in selecting and
    integrating components of the system.
Links
   http://linux-bangalore.org/blug/meetings/200401/scheduler-2.6.pdf
   http://www.netbsd.org/ - One site for all NetBSD stuff
   http://people.freebsd.org/~jlemon/papers/kqueue.pdf       - Kqueue design
   http://camars.kaist.ac.kr/courses/530/97/Readings/scheduler-act.pdf - SA design
   http://josh.trancesoftware.com/linux/ - Details of Linux 2.6 scheduler
   http://www.wasabisystems.com/gpl/linux.htm - A comparison
   http://bulk.fefe.de/scalability/   - Started a Battle and cleanup !!
   http://lkcd.sourceforge.net/
   http://kgdb.sf.net/
   http://oss.sgi.com/projects/kdb/
   http://www.linuxjournal.com/article/3829 - Using Linux Trace Toolkit
   http://www.opersys.com/LTT
   http://netbsd-soc.sourceforge.net/projects/tmpfs/ - TMPFS project page
   http://www.selenic.com/linux-tiny      - Linux Tiny home page
Finally ...
   Questions ??
   Thanks to
    –   Organizers for giving me a chance to speak at FOSS.in
    –   NetBSD and Linux developers who helped me during my work
    –   Linux kernel team for doing a wonderful job !!
   Special thanks to YOU for listening...


                       You can contact me at :
                    Mahendra_M@infosys.com

Más contenido relacionado

La actualidad más candente

Embedded_Linux_Booting
Embedded_Linux_BootingEmbedded_Linux_Booting
Embedded_Linux_Booting
Rashila Rr
 
Embedded Operating System - Linux
Embedded Operating System - LinuxEmbedded Operating System - Linux
Embedded Operating System - Linux
Emertxe Information Technologies Pvt Ltd
 

La actualidad más candente (20)

Static partitioning virtualization on RISC-V
Static partitioning virtualization on RISC-VStatic partitioning virtualization on RISC-V
Static partitioning virtualization on RISC-V
 
BeagleBone Black Booting Process
BeagleBone Black Booting ProcessBeagleBone Black Booting Process
BeagleBone Black Booting Process
 
Parallelism in a NumPy-based program
Parallelism in a NumPy-based programParallelism in a NumPy-based program
Parallelism in a NumPy-based program
 
BeagleBone Black Bootloaders
BeagleBone Black BootloadersBeagleBone Black Bootloaders
BeagleBone Black Bootloaders
 
Embedded Linux Quick Start Guide v1.5
Embedded Linux Quick Start Guide v1.5Embedded Linux Quick Start Guide v1.5
Embedded Linux Quick Start Guide v1.5
 
OpenWrt From Top to Bottom
OpenWrt From Top to BottomOpenWrt From Top to Bottom
OpenWrt From Top to Bottom
 
U-Boot - An universal bootloader
U-Boot - An universal bootloader U-Boot - An universal bootloader
U-Boot - An universal bootloader
 
Introduction to systemd
Introduction to systemdIntroduction to systemd
Introduction to systemd
 
Xvisor: embedded and lightweight hypervisor
Xvisor: embedded and lightweight hypervisorXvisor: embedded and lightweight hypervisor
Xvisor: embedded and lightweight hypervisor
 
Building Embedded Linux Full Tutorial for ARM
Building Embedded Linux Full Tutorial for ARMBuilding Embedded Linux Full Tutorial for ARM
Building Embedded Linux Full Tutorial for ARM
 
Understanding eBPF in a Hurry!
Understanding eBPF in a Hurry!Understanding eBPF in a Hurry!
Understanding eBPF in a Hurry!
 
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
 
QEMU and Raspberry Pi. Instant Embedded Development
QEMU and Raspberry Pi. Instant Embedded DevelopmentQEMU and Raspberry Pi. Instant Embedded Development
QEMU and Raspberry Pi. Instant Embedded Development
 
Linux Boot Process
Linux Boot ProcessLinux Boot Process
Linux Boot Process
 
Build your own embedded linux distributions by yocto project
Build your own embedded linux distributions by yocto projectBuild your own embedded linux distributions by yocto project
Build your own embedded linux distributions by yocto project
 
Embedded_Linux_Booting
Embedded_Linux_BootingEmbedded_Linux_Booting
Embedded_Linux_Booting
 
Embedded Operating System - Linux
Embedded Operating System - LinuxEmbedded Operating System - Linux
Embedded Operating System - Linux
 
Kernel Debugging & Profiling
Kernel Debugging & ProfilingKernel Debugging & Profiling
Kernel Debugging & Profiling
 
Linux Kernel Overview
Linux Kernel OverviewLinux Kernel Overview
Linux Kernel Overview
 
Early Software Development through Palladium Emulation
Early Software Development through Palladium EmulationEarly Software Development through Palladium Emulation
Early Software Development through Palladium Emulation
 

Destacado

Wind River Chumby Motorola Stacatto
Wind River   Chumby   Motorola   StacattoWind River   Chumby   Motorola   Stacatto
Wind River Chumby Motorola Stacatto
Marco Thompson
 
Introduction to Embedded Systems
Introduction to Embedded SystemsIntroduction to Embedded Systems
Introduction to Embedded Systems
Anil Kumar Pugalia
 

Destacado (19)

Advanced task management with Celery
Advanced task management with CeleryAdvanced task management with Celery
Advanced task management with Celery
 
Open World of #OSS and #HealthTech
Open World of #OSS and #HealthTechOpen World of #OSS and #HealthTech
Open World of #OSS and #HealthTech
 
Linux, Android and Open Source in the Mobile Environment
Linux, Android and Open Source in the Mobile EnvironmentLinux, Android and Open Source in the Mobile Environment
Linux, Android and Open Source in the Mobile Environment
 
Wind River Chumby Motorola Stacatto
Wind River   Chumby   Motorola   StacattoWind River   Chumby   Motorola   Stacatto
Wind River Chumby Motorola Stacatto
 
Developer Day 2014 - 4 - wind river - iot business and technology trends
Developer Day 2014 - 4 - wind river - iot business and technology trendsDeveloper Day 2014 - 4 - wind river - iot business and technology trends
Developer Day 2014 - 4 - wind river - iot business and technology trends
 
Emotion Economy: Ethnography as Corporate Strategy (Kelly Goto at Enterprise ...
Emotion Economy: Ethnography as Corporate Strategy (Kelly Goto at Enterprise ...Emotion Economy: Ethnography as Corporate Strategy (Kelly Goto at Enterprise ...
Emotion Economy: Ethnography as Corporate Strategy (Kelly Goto at Enterprise ...
 
Embedded Linux Evolution | Turing Techtalk
Embedded Linux Evolution | Turing TechtalkEmbedded Linux Evolution | Turing Techtalk
Embedded Linux Evolution | Turing Techtalk
 
Yocto Project Open Source Build System and Collaboration Initiative
Yocto Project Open Source Build System and Collaboration InitiativeYocto Project Open Source Build System and Collaboration Initiative
Yocto Project Open Source Build System and Collaboration Initiative
 
PyCon India 2012: Celery Talk
PyCon India 2012: Celery TalkPyCon India 2012: Celery Talk
PyCon India 2012: Celery Talk
 
Embedded Os [Linux & Co.]
Embedded Os [Linux & Co.]Embedded Os [Linux & Co.]
Embedded Os [Linux & Co.]
 
Importance of ‘Centralized Event collection’ and BigData platform for Analysis !
Importance of ‘Centralized Event collection’ and BigData platform for Analysis !Importance of ‘Centralized Event collection’ and BigData platform for Analysis !
Importance of ‘Centralized Event collection’ and BigData platform for Analysis !
 
"In love with Open Source : Past, Present and Future" : Keynote OSDConf 2014
"In love with Open Source : Past, Present and Future" : Keynote OSDConf 2014"In love with Open Source : Past, Present and Future" : Keynote OSDConf 2014
"In love with Open Source : Past, Present and Future" : Keynote OSDConf 2014
 
A Market Update on Embedded/Real-Time Operating Systems
A Market Update on Embedded/Real-Time Operating SystemsA Market Update on Embedded/Real-Time Operating Systems
A Market Update on Embedded/Real-Time Operating Systems
 
Filippa K - Goto Market Strategy 2016
Filippa K - Goto Market Strategy 2016Filippa K - Goto Market Strategy 2016
Filippa K - Goto Market Strategy 2016
 
Iot survey
Iot surveyIot survey
Iot survey
 
Radisys_Wind River_C-RAN Webinar_June 26_14
Radisys_Wind River_C-RAN Webinar_June 26_14Radisys_Wind River_C-RAN Webinar_June 26_14
Radisys_Wind River_C-RAN Webinar_June 26_14
 
An Introduction to Celery
An Introduction to CeleryAn Introduction to Celery
An Introduction to Celery
 
Introduction to Embedded Systems
Introduction to Embedded SystemsIntroduction to Embedded Systems
Introduction to Embedded Systems
 
Toolchain
ToolchainToolchain
Toolchain
 

Similar a NetBSD and Linux for Embedded Systems

Introduction to NetBSD kernel
Introduction to NetBSD kernelIntroduction to NetBSD kernel
Introduction to NetBSD kernel
Mahendra M
 
Ospresentation 120112074429-phpapp02 (1)
Ospresentation 120112074429-phpapp02 (1)Ospresentation 120112074429-phpapp02 (1)
Ospresentation 120112074429-phpapp02 (1)
Vivian Vhaves
 
Virtual Distro Dispatcher - A costless distributed virtual environment from T...
Virtual Distro Dispatcher - A costless distributed virtual environment from T...Virtual Distro Dispatcher - A costless distributed virtual environment from T...
Virtual Distro Dispatcher - A costless distributed virtual environment from T...
Flavio Bertini
 
Enea Linux and LWRT FTF China 2012
Enea Linux and LWRT FTF China 2012Enea Linux and LWRT FTF China 2012
Enea Linux and LWRT FTF China 2012
EneaSoftware
 

Similar a NetBSD and Linux for Embedded Systems (20)

Introduction to NetBSD kernel
Introduction to NetBSD kernelIntroduction to NetBSD kernel
Introduction to NetBSD kernel
 
introduction.pdf
introduction.pdfintroduction.pdf
introduction.pdf
 
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
 
Ospresentation 120112074429-phpapp02 (1)
Ospresentation 120112074429-phpapp02 (1)Ospresentation 120112074429-phpapp02 (1)
Ospresentation 120112074429-phpapp02 (1)
 
Linux kernel
Linux kernelLinux kernel
Linux kernel
 
Linux kernel
Linux kernelLinux kernel
Linux kernel
 
Lightweight Virtualization in Linux
Lightweight Virtualization in LinuxLightweight Virtualization in Linux
Lightweight Virtualization in Linux
 
ubantu ppt.pptx
ubantu ppt.pptxubantu ppt.pptx
ubantu ppt.pptx
 
Ubuntu OS Presentation
Ubuntu OS PresentationUbuntu OS Presentation
Ubuntu OS Presentation
 
First steps on CentOs7
First steps on CentOs7First steps on CentOs7
First steps on CentOs7
 
The Linux System
The Linux SystemThe Linux System
The Linux System
 
Chapter 6 os
Chapter 6 osChapter 6 os
Chapter 6 os
 
Linux scheduling and input and output
Linux scheduling and input and outputLinux scheduling and input and output
Linux scheduling and input and output
 
Realizing Linux Containers (LXC)
Realizing Linux Containers (LXC)Realizing Linux Containers (LXC)
Realizing Linux Containers (LXC)
 
Virtual Distro Dispatcher - A costless distributed virtual environment from T...
Virtual Distro Dispatcher - A costless distributed virtual environment from T...Virtual Distro Dispatcher - A costless distributed virtual environment from T...
Virtual Distro Dispatcher - A costless distributed virtual environment from T...
 
multi-threading
multi-threadingmulti-threading
multi-threading
 
Linux for embedded_systems
Linux for embedded_systemsLinux for embedded_systems
Linux for embedded_systems
 
Enea Linux and LWRT FTF China 2012
Enea Linux and LWRT FTF China 2012Enea Linux and LWRT FTF China 2012
Enea Linux and LWRT FTF China 2012
 
Running Applications on the NetBSD Rump Kernel by Justin Cormack
Running Applications on the NetBSD Rump Kernel by Justin Cormack Running Applications on the NetBSD Rump Kernel by Justin Cormack
Running Applications on the NetBSD Rump Kernel by Justin Cormack
 
.ppt
.ppt.ppt
.ppt
 

Último

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Último (20)

Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
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
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 

NetBSD and Linux for Embedded Systems

  • 1. NetBSD and Linux for Embedded Systems 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. About the talk  This talk is NOT about to compare NetBSD and Linux and find out which is better. – We shall compare – but not criticize !!  We shall try to understand both systems in their own merit  It is about sharing our experiences with both the systems – more from a embedded & telecom OS perspective.  We hope to help you choose.
  • 3. Agenda  A short introduction to NetBSD and Linux based systems  Suitability for embedded systems  Introduction to the features available in NB and Linux – Specifically for Embedded Systems  Feature wise comparison of the two kernels – Core architecture, Threading model, Real time capabilities, modularity, performance, ease of deployment, portability  Linux capabilities.  NetBSD Capabilities – Kqueue : Event notification framework  Availability of Code for future needs  Feasibility and time to market along with License issues.
  • 4. About the Systems  Linux – Refers only to the kernel – Distributions are built around it. ( distros available for embedded systems ) – Has a history of around 15 years – Is under the GPL license ( v2.0 ) and supports binary modules.  NetBSD – A BSD “ distribution” targeted at portability. – Includes a kernel, libraries, config tools, scripts and build systems. – Targeted at portability – The BSD systems have had a history of around 25 years. – Is under a BSD license.
  • 5. Common stuff ...  Highly portable – ports exist for a large number of architectures and reference boards.  Both are POSIX compliant  Good VM, Networking, Threading subsystems  Both have been time tested in the market  Active development happening – Directly on Linux kernel – on multiple trees maintained by different people. – NetBSD tend to let features stabilize on FreeBSD/OpenBSD and then pick it up :-)  Let us get on with the differences....
  • 6. Memory foot print  Linux is slowly getting bloated. – There are projects that are working on reducing the size of Linux kernel – “ Linux Tiny” project provides a set of patches that can be applied to the Linux kernel to reduce the kernel size (built image and run time memory requirements)  NetBSD projects boast of reduced kernel size. – TINY configuration file is distributed along with the source.  Both kernels can be easily reduced to a size of less than 1MB ( uncompressed : ~900k, compressed : ~400k )  With sufficient hacking around, it can be reduced even further.
  • 7. Process Scheduling  Both OS follow a similar model in running user space processes. – Time slice based – and O(1) in nature. – They have priority based levels and processes are placed on these levels based on their priority – Both support dynamic priority modification based on interactiveness of a process  Not needed for embedded systems – and can be turned off at compile time. – Both support the same user space priorities (40)  Linux has two run-queues : An active and an expired run- queue.  Linux also has a run-queue per CPU – for SMP boxes.
  • 8. Process Run-queue RunQueue Doubly linked lists of tasks Active Task 1 Task 2 ... Task N [Priority: 1] ... Task 1 Task 2 Task M [Priority:140] Expired ... ... Migration Thread From kernel/sched.c
  • 9. Other stuff ...  Kernel pre-emption. – Linux kernel supports kernel pre-emption, but only at pre- emptible points inside in the kernel. – There are still areas within the kernel which cannot be pre- empted. – NetBSD does not support kernel pre-emption.  Hence real-time support is pretty poor on NetBSD systems  SMP Support ( not really critical in embedded systems ) – Very good in Linux. – Worked upon in NetBSD.
  • 10. Real-time performance  Hard real-time performance – Not available in both kernels by default. – FSM labs provides patches to the Linux kernel ( under GPL ) and commercial patches to NetBSD.  Works by running Linux/NetBSD kernel as low priority tasks under a real time kernel.  Soft real-time performance. – Linux is pretty good in providing soft real time facilities. – In addition to the 40 user land priorities, Linux provides an additional 100 real-time priorities – Linux supports two soft real time scheduling options  SCHED_FIFO – First in first out  SCHED_RR – Round robin – Real time tasks cannot be pre-empted.
  • 11. Threading models  Both kernels are thread aware and are POSIX compliant  They support different threading models – This is where the difference starts and things get interesting..  Linux – 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
  • 12. Threading models ( 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.  Both groups had debated the models before taking up their approaches. Both methods are “ claimed” to be better than the other.  Today, Linux seems to have better thread/process creation, spawning and context switching times.
  • 13. Debugging support  NetBSD has much better debugging support. – DDB – an in-kernel debugger – Supports kernel crash dumps – Supports KGDB (source level debug) – remote debugging.  Linux – Patches available for crash dumps and KDB & KGDB (not available for all architectures) – Linux Trace Toolkit, UML etc. are also available methods. – Has “ Kernel Hacking” Option in kernel configuration  Allows debugging using “ Magic SysRQs” , Debugging of actions like memory allocations, file systems, highmem, stack overflows, page allocations etc.  Also allows stats collection for some modules. – Also, early printk() support is pretty recent.
  • 14. Flash Devices and File Systems  Support is poor in NetBSD  Linux supports – Advanced MTD support ( device concatenation, FTL, NFTL ) – JFFS2 ( JFFS3 is being worked on ) – RAM file systems and ramdisk support – Supports initrd  In NetBSD – OpenSource implementations of the above are not available. ( Commercial products are available ) – Results in considerable lead time in development. – Supports MFS ( not memory efficient ) : tmpfs is being worked upon – For boot time, it allows embedding a file-system into the kernel
  • 15. 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 !!
  • 16. Build systems and configuration  NetBSD is better – 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.  Linux – Such systems exist but it is not as flexible as BSD  Both NetBSD and Linux provide different configuration mechanisms. – NetBSD builds a device tree format. – Linux provides a GUI interface for configuring the kernel...
  • 17. Other differences.  Linux kernel code throws out lot of warnings during compilation. NetBSD is very clean in this aspect.  Linux supports MMU Less operations.  Loadable kernel modules – Better supported in Linux.  Better device support in Linux  With 2.6 kernel, the device driver model has vastly improved ( attend other talks at FOSS.in for more details )  Portability has been a design goal for NetBSD.  Development models are vastly different :-) – NetBSD is more “ cathedral” like !!  In Linux, you get answers easily :-)
  • 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 and Linux. – To be more portable, they tend to ignore benefits of one OS  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.  In case of Linux, extra time is required in selecting and integrating components of the system.
  • 19. Links  http://linux-bangalore.org/blug/meetings/200401/scheduler-2.6.pdf  http://www.netbsd.org/ - One site for all NetBSD stuff  http://people.freebsd.org/~jlemon/papers/kqueue.pdf - Kqueue design  http://camars.kaist.ac.kr/courses/530/97/Readings/scheduler-act.pdf - SA design  http://josh.trancesoftware.com/linux/ - Details of Linux 2.6 scheduler  http://www.wasabisystems.com/gpl/linux.htm - A comparison  http://bulk.fefe.de/scalability/ - Started a Battle and cleanup !!  http://lkcd.sourceforge.net/  http://kgdb.sf.net/  http://oss.sgi.com/projects/kdb/  http://www.linuxjournal.com/article/3829 - Using Linux Trace Toolkit  http://www.opersys.com/LTT  http://netbsd-soc.sourceforge.net/projects/tmpfs/ - TMPFS project page  http://www.selenic.com/linux-tiny - Linux Tiny home page
  • 20. Finally ...  Questions ??  Thanks to – Organizers for giving me a chance to speak at FOSS.in – NetBSD and Linux developers who helped me during my work – Linux kernel team for doing a wonderful job !!  Special thanks to YOU for listening... You can contact me at : Mahendra_M@infosys.com