OS – Ex 1 Nezer J. Zaidenberg.

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

Computer System Laboratory
Compilation and Debugging 101. Compilation in C/C++ hello.c Preprocessor Compiler stdio.h tmpXQ.i (C code) hello.o (object file)
Building and Running Modules Sarah Diesburg COP 5641.
Building and Running Modules Linux Kernel Programming CIS 4930/COP 5641.
Linking & Loading CS-502 Operating Systems
52 Advanced Operating Systems Writing Device Drivers.
Copyright © 2008 Pearson Addison-Wesley. All rights reserved. Chapter 12 Separate Compilation Namespaces Simple Make Files (Ignore all class references.
1 CSE 451 Section Autumn 2004 Alex Moshchuk Office hours: Tue 1-2, Thu 4:30-5:30 Allen 218 (or lab)
CSE 451 Section Autumn 2005 Richard Dunn Office hours: WTh 3:30-4:20 Allen 216 (or lab)
How to make a pseudo-file As a follow-up to our first lab, we examine the steps needed to create our own ‘/proc’ file.
Embedded System Programming Introduction to Device Drivers.
Add a New System Call to Linux. Hw1 Add a New System Call to Linux and Compile Kernel Add a New System Call to Linux by Kernel Module.
Loadable Kernel Modules Dzintars Lepešs The University of Latvia.
Kernel module programming Nezer J. Zaidenberg. reference This guide is built on top of The Linux Kernel Module Programming Guide The guide is available.
The preprocessor and the compilation process COP3275 – PROGRAMMING USING C DIEGO J. RIVERA-GUTIERREZ.
Operating System Program 5 I/O System DMA Device Driver.
1 Nachos Introduction Lecturer: Tei-Wei Kuo TA: Ya-Su Chen, Yuan-Hao chang Date: 2005/10/19.
For OS Experiments. What Do We Need? A Computer &
Homework There will be 4 homework assignments There will be 4 homework assignments They will each be graded (There will be bonus) They will each.
C O M P U T E R G R A P H I C S Jie chen Computer graphic -- OpenGL Howto.
Sogang University Advanced Operating Systems (Linux Module Programming) Sang Gue Oh, Ph.D.
1 What is a Kernel The kernel of any operating system is the core of all the system’s software. The only thing more fundamental than the kernel is the.
CS 444 Introduction to Operating Systems
CS 390 Unix Programming Summer Unix Programming - CS 3902 Course Details Online Information Please check.
1 Lab 2 “Hello world” in Unix/Linux #include "std_lib_facilities_4.h" int main(){ cout
Multiple Files. Monolithic vs Modular  one file before  system includes  main driver function  prototypes  function.
Troubleshooting and Performance
Kernel Modules. Kernel Module Pieces of code that can be loaded and unloaded into the kernel upon demand. Compiled as an independent program With appropriate.
Chapter 0 Getting Started. Objectives Understand the basic structure of a C++ program including: – Comments – Preprocessor instructions – Main function.
Linux Kernel Management. Module 9 – Kernel Administration ♦ Overview The innermost layer of Linux operating system is the kernel, which is a thin layer.
LOGO System Call. Introduction System call is the mechanism used by an application program to request service from the OS. Users use it to communicate.
Nachos Overview Lecturer: Hao-Hua Chu TA: Chun-Po Wang (Artoo) Date: 2008/09/18 Material Provided by Yuan-Hao Chang, Yung-Feng Lu.
Lab 12 Department of Computer Science and Information Engineering National Taiwan University Lab12 – Driver 2014/12/16 1 /21.
Linux Kernel Programming (LKP). LKP New sub-course New sub-course We will learn together We will learn together Evaluation of this part of course will.
Computer Programming A simple example /* HelloWorld: A simple C program */ #include int main (void) { printf (“Hello world!\n”); return.
CSE 451 Section Autumn 2004 Alex Moshchuk Office hours: Tue 2-3, Thu 4:30-5:30 Allen 216 (or lab)
GNU and Linux.
Add a New System Call to Linux
Introduction to C Topics Compilation Using the gcc Compiler
Exercise #1: Exploring Open-Source Operating Systems with Virtual Machines J. H. Wang Sep. 20, 2016.
UMBC CMSC 104 – Section 01, Fall 2016
CS1010: Intro Workshop.
CSC227: Operating Systems
Linux Kernel Module Programming
Computer System Laboratory
Algorithms Problem: Write pseudocode for a program that keeps asking the user to input integers until the user enters zero, and then determines and outputs.
Linking & Loading.
Linux Kernel Module Programming
Exercise #1: Exploring Open-Source Operating Systems with Virtual Machines J. H. Wang Sep. 19, 2017.
CS-3013 Operating Systems C-term 2008
Want to play a game? – Linux Kernel Modules
Operation System Program 4
Intro to Kernel Modules and /proc
OPS235: Week 1 Installing Linux ( Lab1: Investigations 1-4)
Exercise #1: Exploring Open-Source Operating Systems with Virtual Machines J. H. Wang Sep. 21, 2018.
Operating Systems Lecture 4.
Kernel Structure and Infrastructure
COP 4343 Unix System Administration
CS 6560 Operating System Design
OPS235: Week 1 Installing Linux ( Lab1: Investigations 1-4)
Lab 4 Kernel Module Operating System Lab.
Linking & Loading CS-502 Operating Systems
CS 6560 Operating System Design Kernel Loadable Modules
Implementation of Embedded OS
Computer System Laboratory
Chapter 2: Operating-System Structures
Loadable Kernel Modules
Linking & Loading CS-502 Operating Systems
Sarah Diesburg Operating Systems CS 3430
Presentation transcript:

OS – Ex 1 Nezer J. Zaidenberg

Administration Nezer J. Zaidenberg nzaidenberg@mac.com I sit in Schreiber 9 Ex. Grader TBD THE COURSE HAS BEEN MODIFIED PLEASE ATTEND LECTURES EVEN IF YOU DO THIS COURSE 2ND TIME

Homework There will be 4 homework assignments They will each be graded 0-100+ (bonus may apply) Total weight = 40% (total weight of test = 70%) Homework can be done in groups Each group must meet the ex. Checker and explain their work. a group were a single member will fail to explain his work will fail The homework will be checked on a computer with VMWare that you should download and verify No rechecks for code that doesn’t run!!! No points will be deducted on code quality (unless we see real atrocities) but points will be dedicted if the ex doesn’t work as supposed to or use the OS incorrectly

Using Linux The good but hard way – install Fedora core 9 on your computer. (Do this if you know what you are doing and at your own risk) The also possible way – download VM Player from VMWare.com (free) and use it with our vmware. Download Linux vmware We will distribute Vmware machine you can work on. There will also be method to invoke from university servers. The not recommended ways Using only user mode linux Using your own different linux distribution Using another UNIX ETC… all those methods are at your own risks. Should anything fail, you will be sole responsible due to all incompatibilities.

Using Linux under VMPlayer Simulates mini computer inside your computer. Maybe slow but good enough for us. For most practical purposes can be treated as a real computer with real OS. (certainly for this course) Root password : qwerty User password : user Download from www.scipio.org/OS_Course

User vs Root User – can run programs Root – can run system programs. Administrator of system (usually owner or owner’s employee) User – can hardly cause damages. Root – prune to damages. Root – can use low-level system resources (such as row sockets) and setup kernel modules Most of the time we work as user; Sometimes(rarely) we work as root. When coding stuff on the kernel or running administration commands

What is kernel module Kernel module, (in simplest terms) is part of the OS, that can be insert into the OS and removed at run time. We can modify the OS by attaching kernel modules to the kernel Anybody can compile kernel modules but only root can insert them to a running system

Commands that deal with kernel modules What modules are running? = lsmod Insert a module – insmod or modprobe (modprobe also support parameters) Remove a module – rmmod or modprobe –r

Coding in kernel space In kernel space the standard library (functions such as printf() etc.) doesn’t exist. Kernel developers have implemented kernel replications of most standard library functions. References Chapter 21 of beginning linux programming by Stones & Matthew Understanding the Linux kernel

Compiling “hello world” kernel module This exercise will teach you how to write kernel module that prints “hello world” Compiling gcc –D__KERNEL__ -D__SMP__ -DMODULE –DMODVERSIONS –I/usr/src/linux/include –Wall –O2 –o module.o –c module.c Meanings __KERNEL__ = some kernel headers are also used in user process. This makes all #ifndef __KERNEL__ pick the correct code. __SMP__ = this module will be used in SMP system (practically all desktop computers when you will graduate will be SMP) MODULE = must be defined for the code to be compiled as kernel module MODVERSIONS = include module and kernel version (so that we will not load incorrect module into the kernel) -I/usr/src/linux/include = linux include source. (such as what replaces std lib and the OS headers itself)

Kernel module functions and source Every kernel module must include <linux/module.h> and every kernel module with modversions must include <linux/modversions.h> Also each kernel module must implement init_module() and cleanup_module() function. (In OOD that would be called an “Interface”

Code #include <linux/module.h> #ifdef CONFIG_SMP #define __SMP__ #endif #ifdef CONFIG_MODVERSIONS #define MODVERSIONS #include <linux/kernel.h>

Code continue Int init_module(void) { printk(KERN_ALERT, “hello, world\n”); } Void cleanup_module(void) printk(KERN_DEBUG, “bye bye cruel world\n”)

Explaining #macros -> will be explained later. So far treat them as a must Init, cleanup function = the interface Printk = a printf (or maybe syslog(2) type function that will send info to a file there is no libc in the kernel KERN_DEBUG = one of several levels of debug messages Other levels KERN_EMERG, KERN_ALERT, KERN_CRIT, KERN_ERR, KERN_WARN, KERN_NOTICE)

Homework – not for submission Run the above code Check for kernel messages in /var/log Try to find out what kernel message level is the threshold in your machine