Want to play a game? – Linux Kernel Modules

Slides:



Advertisements
Similar presentations
DEVICE DRIVER VINOD KAMATH CS691X PROJECT WORK. Introduction How to write/install device drivers Systems, Kernel Programming Character, Block and Network.
Advertisements

Linux device-driver issues
Device Drivers. Linux Device Drivers Linux supports three types of hardware device: character, block and network –character devices: R/W without buffering.
Computer System Laboratory
Operating System Structures
More on Processes Chapter 3. Process image _the physical representation of a process in the OS _an address space consisting of code, data and stack segments.
Using VMX within Linux We explore the feasibility of executing ROM-BIOS code within the Linux x86_64 kernel.
Processes CSCI 444/544 Operating Systems Fall 2008.
1 CS 333 Introduction to Operating Systems Class 2 – OS-Related Hardware & Software The Process Concept Jonathan Walpole Computer Science Portland State.
Embedded Real-time Systems The Linux kernel. The Operating System Kernel Resident in memory, privileged mode System calls offer general purpose services.
Advanced OS Chapter 3p2 Sections 3.4 / 3.5. Interrupts These enable software to respond to signals from hardware. The set of instructions to be executed.
1 Device Management The von Neumann Architecture System Architecture Device Management Polling Interrupts DMA operating systems.
1 Process Description and Control Chapter 3 = Why process? = What is a process? = How to represent processes? = How to control processes?
1 I/O Management in Representative Operating Systems.
Process Description and Control A process is sometimes called a task, it is a program in execution.
Copyright Arshi Khan1 System Programming Instructor Arshi Khan.
I/O Tanenbaum, ch. 5 p. 329 – 427 Silberschatz, ch. 13 p
Operating System Program 5 I/O System DMA Device Driver.
OPERATING SYSTEM OVERVIEW. Contents Basic hardware elements.
Programming With C.
Lecture 3 Process Concepts. What is a Process? A process is the dynamic execution context of an executing program. Several processes may run concurrently,
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 2: Operating-System Structures.
Operating Systems Lecture 7 OS Potpourri Adapted from Operating Systems Lecture Notes, Copyright 1997 Martin C. Rinard. Zhiqing Liu School of Software.
UNIX Files File organization and a few primitives.
NT Kernel CS Spring Overview Interrupts and Exceptions: Trap Handler Interrupt Request Levels and IRT DPC’s, and APC’s System Service Dispatching.
LINUX System : Lecture 7 Bong-Soo Sohn Lecture notes acknowledgement : The design of UNIX Operating System.
Operating Systems Lecture November 2015© Copyright Virtual University of Pakistan 2 Agenda for Today Review of previous lecture Hardware (I/O, memory,
OS2014 PROJECT 2 Supplemental Information. Outline Sequence Diagram of Project 2 Kernel Modules Kernel Sockets Work Queues Synchronization.
Processes and Process Control 1. Processes and Process Control 2. Definitions of a Process 3. Systems state vs. Process State 4. A 2 State Process Model.
We will focus on operating system concepts What does it do? How is it implemented? Apply to Windows, Linux, Unix, Solaris, Mac OS X. Will discuss differences.
Multi-Tasking The Multi-Tasking service is offered by VxWorks with its real- time kernel “WIND”.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 14 Threads 2 Read Ch.
Operating Systems CSE 411 CPU Management Sept Lecture 10 Instructor: Bhuvan Urgaonkar.
Processes, Threads, and Process States. Programs and Processes  Program: an executable file (before/after compilation)  Process: an instance of a program.
Processor Structure and Function Chapter8:. CPU Structure  CPU must:  Fetch instructions –Read instruction from memory  Interpret instructions –Instruction.
Lab 12 Department of Computer Science and Information Engineering National Taiwan University Lab12 – Driver 2014/12/16 1 /21.
COMP 3438 – Part I - Lecture 5 Character Device Drivers
Device Driver Concepts Digital UNIX Internals II Device Driver Concepts Chapter 13.
Introduction Contain two or more CPU share common memory and peripherals. Provide greater system throughput. Multiple processor executing simultaneous.
1 Lecture 19: Unix signals and Terminal management n what is a signal n signal handling u kernel u user n signal generation n signal example usage n terminal.
CSCI/CMPE 4334 Operating Systems Review: Exam 1 1.
1 Chapter 2: Operating-System Structures Services Interface provided to users & programmers –System calls (programmer access) –User level access to system.
CSCE451/851 Introduction to Operating Systems
Introduction to Operating Systems Concepts
Input/Output (I/O) Important OS function – control I/O
Exceptional Control Flow
Chapter 2: Operating-System Structures
Introduction to Kernel
OPERATING SYSTEM CONCEPT AND PRACTISE
Zero-copy Receive Path in Virtio
Linux Details: Device Drivers
Interrupts and signals
CS 6560: Operating Systems Design
Protection of System Resources
Computer System Laboratory
Lecture 4: Operating System Structures
Input/Output.
Objectives Identify the built-in data types in C++
Linux Kernel Module Programming
Linux Kernel Driver.
Exceptional Control Flow: System Calls, Page Faults etc.
CSCI 315 Operating Systems Design
Chapter 15, Exploring the Digital Domain
Modified by H. Schulzrinne 02/15/10 Chapter 4: Threads.
Linux Details: Device Drivers
Operating Systems Lecture 3.
LINUX System : Lecture 7 Lecture notes acknowledgement : The design of UNIX Operating System.
Implementation of Embedded OS
CS510 Operating System Foundations
III. Operating System Structures
Presentation transcript:

Want to play a game? – Linux Kernel Modules ID1206 HT17

User space vs. Kernel space Distinction of “rings” within the processor User space programs run in one ring – kernel space in another Allows for execution of privileged or sensitive instructions Helps you not to crash your computer every other hour In this assignment you will write a kernel space program Either by compiling a custom kernel or a kernel module

Kernel Module Macros int main() vs entry and exit functions User-defined and specified by macros ‘module_init’ and ‘module_exit’ MODULE_ macros provides info about the module. License, author etc. printk() Kernel modules doesn’t have a regular terminal thus nowhere to print to If you want to print stuff use the kernel version of printf() Printouts show up in dmesg

Communicating with your kernel module Implementing system calls UNIX’s fetish of the file interface Just make a special file. Reading and writing to and from your module The /proc interface – The file structure representing your kernel A different type of file – not saved ANYWHERE!? Block files, character files and special files – anyone know the difference? /dev, /sys, /proc

file_operations() Each field of the structure corresponds to the address of some function defined by the driver to handle a requested operation. For example, every character driver needs to define a function that reads from the device. The file_operations structure holds the address of the module's function that performs that operation. In this assignment we implement a module providing a file in /proc with the seq_file interface, and a device driver in /dev. Writing to this file is done with the seq_printf() function

The ioctl system call Sending requests to a file Used to manipulate underlying device parameters of special files The kernel module implements a handler function and acts according to the requests made We implement a function that copies a string to a buffer using ‘copy_to_user’

Happy Hacking!