SlideShare una empresa de Scribd logo
1 de 17
Descargar para leer sin conexión
Linux System Programming



    By:
    Ahmed Teirelbar
    Software Engineer
    Shuja' Consulting
Rough Outline
    C
●


        Procedural concepts
    –

        Builds and shared objects
    –

        Transition to OO
    –

    C++
●


        OO concepts
    –

        Design and existing libraries
    –
Outline Cont'd
    Application System Programming
●


        The program in execution:
    –

             Interaction with the system
         ●


             Interaction with other apps
         ●



        Intro to the APIs
    –

    Kernel Module Programming
●


        Driver/Module Concepts
    –

             What do you provide
         ●


             How do you get what you need
         ●



        Overview of bigger picture
    –
C as a Programming Language
    Programming as logic
●



    Language as grammar and syntax
●



    Procedural
●



    Modular
●



    Abstraction/Hiding
●


        C enables it, C++ supports it
    –

    Object-Oriented
●


        C enables it, C++ supports it
    –

    C++: Parametrization or Generic Programming
●
Building
    Generating an executable from code
●


    Concept of Makefile
●


        Compiling -- gcc
    –

        Linking -- ld
    –

        Installation -- install
    –

        Packaging -- package-manager/strip
    –

        Uninstallation
    –

        Cleaning
    –
Compiling
    Preprocessing – cpp
●


    Compiling – gcc
●


    Some important flags (-o, -c, -Wall, -L, -I, -l, -g,
●

    -O, -D, -Wl,)
    Cross compiling
●
Directives and Include
    #include
●


    #define
●


    #ifdef
●


    Include guards
●


    What's in the include?
●


    Include path “”,<>
●
General Guidelines
    Maintainability/Readability
●


        Deterministic modules – no voodoo
    –

        Minimize ripple effect
    –

        Documentation
    –

        Intuitive naming
    –

    Flexibility/Scalability – Growth and Reduction
●


    Usability
●


    Reusability of Code
●
Empty Program
    Every statement ends with ;
●


    Space insensitive
●


    {} scopes
●


    A brief intro to functions
●


    main
●
Data Types
    Primitive/Built-in data type controls:
●


        Storage
    –

        Operation compatibility
    –

    Typical types:
●


        double, float
    –

        int, short, long, long long
    –

        unsigned, unsigned short, unsigned long, unsigned long long
    –

        char, unsigned char – ASCII
    –

    typedef (architecture example)
●
Variables
    Data Type (Domain)
●



    Scope – Variables on stack
●



    Declaration
●


        int x; char c = 'k';
    –

        int x, y;
    –

    Global variables
●



    Qualifiers
●


        static
    –

        extern
    –
Data Represenation

    Writing constants
●


        Hex 0xa3, Octal 0666, Binary 0111b
    –

    Chars
●


        '<c>', ascii value
    –
Data Represenation Cont'd

    printf
●


         printf (“Printing %<sp1> %<sp2> %<sp3>n”, var1, var2,
     –
         var3);
         Type specifiers:
     –

         %x, %u, %i, %d, %f, %lu, %lx, %Lu, %Lx, %c, %s
     –

    scanf
●


         scanf(“<sp1> <sp2> <sp3>”, &var1, &var2, &var3);
     –

         %[*][width][modifiers]type
     –
Operators
    Primary (( ), [ ], ., ->)
●



    Unary (pre/post++, !, ~, &, *)
●



    Arithmetic (*,/,%,+,-)
●



    Bitwise (>>,<<,&,^,|)
●



    Relational (<,>,<=,>=,==,!=)
●



    Logical (&&, ||)
●



    Conditional (? :)
●



    Assignment (=,+=,-=,*=,/=,<<=,>>=, %=,|=,&=,^=)
●
Precedence
                Who gets processed First?
    Primary                     &
●                           ●



    Unary      (Right           ^
●                           ●

    associative)
                                |
                            ●

    *,/,%
●
                                &&
                            ●

    +,-
●
                                ||
                            ●

    >>,<<
●
                                ?:      (Right associative)
                            ●

    >,<,<=,>=
●
                                Assignment     (Right
                            ●

    ==,!=                       associative)
●
Casting
    Explicit cast
●


        char x = 'a'; int y = (int) x;
    –

        int x = 5; char y = (char) x;
    –

    Implicit cast
●


        double a, b, c; int x; c = a*b + x;
    –

        x = a*b + c;
    –

        Signedness
    –
Code Example

Más contenido relacionado

Destacado

Linux programming lecture_notes
Linux programming lecture_notesLinux programming lecture_notes
Linux programming lecture_notes
IMRAN KHAN
 

Destacado (20)

Implementation of Pipe in Linux
Implementation of Pipe in LinuxImplementation of Pipe in Linux
Implementation of Pipe in Linux
 
Valgrind debugger Tutorial
Valgrind debugger TutorialValgrind debugger Tutorial
Valgrind debugger Tutorial
 
Linux programming lecture_notes
Linux programming lecture_notesLinux programming lecture_notes
Linux programming lecture_notes
 
Making a Process (Virtualizing Memory)
Making a Process (Virtualizing Memory)Making a Process (Virtualizing Memory)
Making a Process (Virtualizing Memory)
 
Part 01 Linux Kernel Compilation (Ubuntu)
Part 01 Linux Kernel Compilation (Ubuntu)Part 01 Linux Kernel Compilation (Ubuntu)
Part 01 Linux Kernel Compilation (Ubuntu)
 
The Linux Kernel Implementation of Pipes and FIFOs
The Linux Kernel Implementation of Pipes and FIFOsThe Linux Kernel Implementation of Pipes and FIFOs
The Linux Kernel Implementation of Pipes and FIFOs
 
Valgrind
ValgrindValgrind
Valgrind
 
Part 03 File System Implementation in Linux
Part 03 File System Implementation in LinuxPart 03 File System Implementation in Linux
Part 03 File System Implementation in Linux
 
Understanding of linux kernel memory model
Understanding of linux kernel memory modelUnderstanding of linux kernel memory model
Understanding of linux kernel memory model
 
Kernel-Level Programming: Entering Ring Naught
Kernel-Level Programming: Entering Ring NaughtKernel-Level Programming: Entering Ring Naught
Kernel-Level Programming: Entering Ring Naught
 
Implementation of FIFO in Linux
Implementation of FIFO in LinuxImplementation of FIFO in Linux
Implementation of FIFO in Linux
 
Memory Management in Linux
Memory Management in LinuxMemory Management in Linux
Memory Management in Linux
 
EcmaScript 6 & 7
EcmaScript 6 & 7EcmaScript 6 & 7
EcmaScript 6 & 7
 
Basic Multithreading using Posix Threads
Basic Multithreading using Posix ThreadsBasic Multithreading using Posix Threads
Basic Multithreading using Posix Threads
 
Signal Handling in Linux
Signal Handling in LinuxSignal Handling in Linux
Signal Handling in Linux
 
Linux kernel code
Linux kernel codeLinux kernel code
Linux kernel code
 
Part 02 Linux Kernel Module Programming
Part 02 Linux Kernel Module ProgrammingPart 02 Linux Kernel Module Programming
Part 02 Linux Kernel Module Programming
 
C Programming - Refresher - Part III
C Programming - Refresher - Part IIIC Programming - Refresher - Part III
C Programming - Refresher - Part III
 
Kernel Module Programming
Kernel Module ProgrammingKernel Module Programming
Kernel Module Programming
 
Peek into linux_device_driver_kit
Peek into linux_device_driver_kitPeek into linux_device_driver_kit
Peek into linux_device_driver_kit
 

Similar a sysprog1

Jscript Fundamentals
Jscript FundamentalsJscript Fundamentals
Jscript Fundamentals
rspaike
 
ooc - A hybrid language experiment
ooc - A hybrid language experimentooc - A hybrid language experiment
ooc - A hybrid language experiment
Amos Wenger
 
Yahoo! Mail antispam - Bay area Hadoop user group
Yahoo! Mail antispam - Bay area Hadoop user groupYahoo! Mail antispam - Bay area Hadoop user group
Yahoo! Mail antispam - Bay area Hadoop user group
Hadoop User Group
 

Similar a sysprog1 (20)

sysprog2 Part1
sysprog2 Part1sysprog2 Part1
sysprog2 Part1
 
Introduction to programming c and data-structures
Introduction to programming c and data-structures Introduction to programming c and data-structures
Introduction to programming c and data-structures
 
Introduction to programming c and data structures
Introduction to programming c and data structuresIntroduction to programming c and data structures
Introduction to programming c and data structures
 
Jscript Fundamentals
Jscript FundamentalsJscript Fundamentals
Jscript Fundamentals
 
Effective Object Oriented Design in Cpp
Effective Object Oriented Design in CppEffective Object Oriented Design in Cpp
Effective Object Oriented Design in Cpp
 
Bioinformatica p4-io
Bioinformatica p4-ioBioinformatica p4-io
Bioinformatica p4-io
 
Preon (J-Fall 2008)
Preon (J-Fall 2008)Preon (J-Fall 2008)
Preon (J-Fall 2008)
 
Programming in C Basics
Programming in C BasicsProgramming in C Basics
Programming in C Basics
 
Cbasic
CbasicCbasic
Cbasic
 
clang-intro
clang-introclang-intro
clang-intro
 
C Language
C LanguageC Language
C Language
 
C prog ppt
C prog pptC prog ppt
C prog ppt
 
Odp
OdpOdp
Odp
 
20090422 Www
20090422 Www20090422 Www
20090422 Www
 
ooc - A hybrid language experiment
ooc - A hybrid language experimentooc - A hybrid language experiment
ooc - A hybrid language experiment
 
ooc - A hybrid language experiment
ooc - A hybrid language experimentooc - A hybrid language experiment
ooc - A hybrid language experiment
 
Cpu
CpuCpu
Cpu
 
Python Workshop. LUG Maniapl
Python Workshop. LUG ManiaplPython Workshop. LUG Maniapl
Python Workshop. LUG Maniapl
 
Yahoo! Mail antispam - Bay area Hadoop user group
Yahoo! Mail antispam - Bay area Hadoop user groupYahoo! Mail antispam - Bay area Hadoop user group
Yahoo! Mail antispam - Bay area Hadoop user group
 
Bubbles & Trees with jQuery
Bubbles & Trees with jQueryBubbles & Trees with jQuery
Bubbles & Trees with jQuery
 

Más de Ahmed Mekkawy

Virtualization Techniques & Cloud Compting
Virtualization Techniques & Cloud ComptingVirtualization Techniques & Cloud Compting
Virtualization Techniques & Cloud Compting
Ahmed Mekkawy
 
A look at computer security
A look at computer securityA look at computer security
A look at computer security
Ahmed Mekkawy
 
Networking in Gnu/Linux
Networking in Gnu/LinuxNetworking in Gnu/Linux
Networking in Gnu/Linux
Ahmed Mekkawy
 

Más de Ahmed Mekkawy (20)

Securing Governmental Public Services with Free/Open Source Tools - Egyptian ...
Securing Governmental Public Services with Free/Open Source Tools - Egyptian ...Securing Governmental Public Services with Free/Open Source Tools - Egyptian ...
Securing Governmental Public Services with Free/Open Source Tools - Egyptian ...
 
OpenData for governments
OpenData for governmentsOpenData for governments
OpenData for governments
 
Infrastructure as a Code
Infrastructure as a Code Infrastructure as a Code
Infrastructure as a Code
 
شركة سبيرولا للأنظمة والجمعية المصرية للمصادر المفتوحة
شركة سبيرولا للأنظمة والجمعية المصرية للمصادر المفتوحةشركة سبيرولا للأنظمة والجمعية المصرية للمصادر المفتوحة
شركة سبيرولا للأنظمة والجمعية المصرية للمصادر المفتوحة
 
Everything is a Game
Everything is a GameEverything is a Game
Everything is a Game
 
Why Cloud Computing has to go the FOSS way
Why Cloud Computing has to go the FOSS wayWhy Cloud Computing has to go the FOSS way
Why Cloud Computing has to go the FOSS way
 
FOSS Enterpreneurship
FOSS EnterpreneurshipFOSS Enterpreneurship
FOSS Enterpreneurship
 
Intro to FOSS & using it in development
Intro to FOSS & using it in developmentIntro to FOSS & using it in development
Intro to FOSS & using it in development
 
FOSS, history and philosophy
FOSS, history and philosophyFOSS, history and philosophy
FOSS, history and philosophy
 
Virtualization Techniques & Cloud Compting
Virtualization Techniques & Cloud ComptingVirtualization Techniques & Cloud Compting
Virtualization Techniques & Cloud Compting
 
A look at computer security
A look at computer securityA look at computer security
A look at computer security
 
Networking in Gnu/Linux
Networking in Gnu/LinuxNetworking in Gnu/Linux
Networking in Gnu/Linux
 
Foss Movement In Egypt
Foss Movement In EgyptFoss Movement In Egypt
Foss Movement In Egypt
 
Sysprog17
Sysprog17Sysprog17
Sysprog17
 
Sysprog 15
Sysprog 15Sysprog 15
Sysprog 15
 
Sysprog 9
Sysprog 9Sysprog 9
Sysprog 9
 
Sysprog 14
Sysprog 14Sysprog 14
Sysprog 14
 
Sysprog 11
Sysprog 11Sysprog 11
Sysprog 11
 
Sysprog 7
Sysprog 7Sysprog 7
Sysprog 7
 
Sysprog 8
Sysprog 8Sysprog 8
Sysprog 8
 

Último

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 

Último (20)

The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
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
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
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
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
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...
 
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
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
[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
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
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
 

sysprog1

  • 1. Linux System Programming By: Ahmed Teirelbar Software Engineer Shuja' Consulting
  • 2. Rough Outline C ● Procedural concepts – Builds and shared objects – Transition to OO – C++ ● OO concepts – Design and existing libraries –
  • 3. Outline Cont'd Application System Programming ● The program in execution: – Interaction with the system ● Interaction with other apps ● Intro to the APIs – Kernel Module Programming ● Driver/Module Concepts – What do you provide ● How do you get what you need ● Overview of bigger picture –
  • 4. C as a Programming Language Programming as logic ● Language as grammar and syntax ● Procedural ● Modular ● Abstraction/Hiding ● C enables it, C++ supports it – Object-Oriented ● C enables it, C++ supports it – C++: Parametrization or Generic Programming ●
  • 5. Building Generating an executable from code ● Concept of Makefile ● Compiling -- gcc – Linking -- ld – Installation -- install – Packaging -- package-manager/strip – Uninstallation – Cleaning –
  • 6. Compiling Preprocessing – cpp ● Compiling – gcc ● Some important flags (-o, -c, -Wall, -L, -I, -l, -g, ● -O, -D, -Wl,) Cross compiling ●
  • 7. Directives and Include #include ● #define ● #ifdef ● Include guards ● What's in the include? ● Include path “”,<> ●
  • 8. General Guidelines Maintainability/Readability ● Deterministic modules – no voodoo – Minimize ripple effect – Documentation – Intuitive naming – Flexibility/Scalability – Growth and Reduction ● Usability ● Reusability of Code ●
  • 9. Empty Program Every statement ends with ; ● Space insensitive ● {} scopes ● A brief intro to functions ● main ●
  • 10. Data Types Primitive/Built-in data type controls: ● Storage – Operation compatibility – Typical types: ● double, float – int, short, long, long long – unsigned, unsigned short, unsigned long, unsigned long long – char, unsigned char – ASCII – typedef (architecture example) ●
  • 11. Variables Data Type (Domain) ● Scope – Variables on stack ● Declaration ● int x; char c = 'k'; – int x, y; – Global variables ● Qualifiers ● static – extern –
  • 12. Data Represenation Writing constants ● Hex 0xa3, Octal 0666, Binary 0111b – Chars ● '<c>', ascii value –
  • 13. Data Represenation Cont'd printf ● printf (“Printing %<sp1> %<sp2> %<sp3>n”, var1, var2, – var3); Type specifiers: – %x, %u, %i, %d, %f, %lu, %lx, %Lu, %Lx, %c, %s – scanf ● scanf(“<sp1> <sp2> <sp3>”, &var1, &var2, &var3); – %[*][width][modifiers]type –
  • 14. Operators Primary (( ), [ ], ., ->) ● Unary (pre/post++, !, ~, &, *) ● Arithmetic (*,/,%,+,-) ● Bitwise (>>,<<,&,^,|) ● Relational (<,>,<=,>=,==,!=) ● Logical (&&, ||) ● Conditional (? :) ● Assignment (=,+=,-=,*=,/=,<<=,>>=, %=,|=,&=,^=) ●
  • 15. Precedence Who gets processed First? Primary & ● ● Unary (Right ^ ● ● associative) | ● *,/,% ● && ● +,- ● || ● >>,<< ● ?: (Right associative) ● >,<,<=,>= ● Assignment (Right ● ==,!= associative) ●
  • 16. Casting Explicit cast ● char x = 'a'; int y = (int) x; – int x = 5; char y = (char) x; – Implicit cast ● double a, b, c; int x; c = a*b + x; – x = a*b + c; – Signedness –