Operating System System Call & Debugging Technique

Similar documents
Creating a system call in Linux. Tushar B. Kute,

Process Environment. Pradipta De

W4118: interrupt and system call. Junfeng Yang

Memory Management Day 2. SWE3015 Sung- hun Kim

Operating Systems (234123) Spring 2017 (Homework Wet 1) Homework 1 Wet

Ftrace - What s new. Since my last explanation of ftrace (from v3.18) Steven Rostedt 25/10/ VMware Inc. All rights reserved.

Linux multi-core scalability

University of Colorado at Colorado Springs CS4500/ Fall 2018 Operating Systems Project 1 - System Calls and Processes

Lecture 3: Processes. CMPUT 379, Section A1, Winter 2014 January 13, 15 and 17

This lecture is covered in Section 4.1 of the textbook.

Section 1: Tools. Contents CS162. January 19, Make More details about Make Git Commands to know... 3

Linux ftrace, , Android Systrace. Android [2][3]. Linux ftrace. Linux. Intel VTune[6] perf timechart[7]. ,, GPU Intel. .

Operating System Labs. Yuanbin Wu

CS Lab 1 xv6 Introduction Setup and exercise

Virtual Memory Paging

CS153: Process. Chengyu Song. Slides modified from Harsha Madhyvasta, Nael Abu-Ghazaleh, and Zhiyun Qian

Shell Code For Beginners

Operating System Project / Lecture 1 Tasks and scheduling. Bon Keun Seo

Debugging realtime application with Ftrace

Helping Developers Help You. Tom Caputi

RAS Enhancement Activities for Mission-Critical Linux Systems

Distribution Kernel Security Hardening with ftrace

Porting Linux to a New Architecture

Prepared by Prof. Hui Jiang Process. Prof. Hui Jiang Dept of Electrical Engineering and Computer Science, York University

Process Description and Control

Porting Linux to a New Architecture

Process. Prepared by Prof. Hui Jiang Dept. of EECS, York Univ. 1. Process in Memory (I) PROCESS. Process. How OS manages CPU usage? No.

Process. Heechul Yun. Disclaimer: some slides are adopted from the book authors slides with permission

COMP 3430 Robert Guderian

Linux Strace tool user guide

CS 0449 Project 4: /dev/rps Due: Friday, December 8, 2017, at 11:59pm

PROCESS VIRTUAL MEMORY PART 2. CS124 Operating Systems Winter , Lecture 19

CS 502 Support. Queue Management State Printers and Output Philosophy. Release Revised 6/2018

Userspace Application Tracing with Markers and Tracepoints

SystemTap Tutorial - Part 1

CPU/Process Management : Objectives & Challenges. Data Structures for CPU Management

PROCESS MANAGEMENT. Operating Systems 2015 Spring by Euiseong Seo

John A. Ronciak Staff Engineer NCG/NID/LAO Intel Corp.

Project #1 Exceptions and Simple System Calls

Project 1: Syscalls for synchronization 1

CS24: INTRODUCTION TO COMPUTING SYSTEMS. Spring 2015 Lecture 25

Lecture Topics. Announcements. Today: Threads (Stallings, chapter , 4.6) Next: Concurrency (Stallings, chapter , 5.

Project 2: Android Scheduler

Ftrace Kernel Hooks: More than just tracing. Presenter: Steven Rostedt Red Hat

Processes. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Dynamic Linux Kernel Instrumentation with SystemTap Eugene Teo, RHCE, RHCX

P6/Linux Memory System Nov 11, 2009"

Kernel Internals. Course Duration: 5 days. Pre-Requisites : Course Objective: Course Outline

Linux Memory Management

Linux Kernel Module Programming. Tushar B. Kute,

COP 4610: Introduction to Operating Systems (Spring 2016) Chapter 3: Process. Zhi Wang Florida State University

Hint #1. Define a syscall

EE516: Embedded Software Project 1. Setting Up Environment for Projects

Term Project Phase I: System Calls

CS 423 Operating System Design: Introduction to Linux Kernel Programming (MP1 Q&A)

Dynamic Recrea,on of Kernel Data Structures for Live Forensics. Andrew Case, Lodovico Marziale, Golden G. Richard III DFRWS 2010

THE PROCESS ABSTRACTION. CS124 Operating Systems Winter , Lecture 7

Frequently asked questions from the previous class survey

System Calls (Φροντιστήριο για την 3η σειρά) Dimitris Deyannis

IA32/Linux Virtual Memory Architecture

Introduction p. 1 Why Linux? p. 2 Embedded Linux Today p. 3 Open Source and the GPL p. 3 Free Versus Freedom p. 4 Standards and Relevant Bodies p.

SOFTWARE ARCHITECTURE 3. SHELL

Enhancement Activities on the Current Upstream Kernel for Mission-Critical Systems

Processes & Threads. Today. Next Time. ! Process concept! Process model! Implementing processes! Multiprocessing once again. ! More of the same J

CS24: INTRODUCTION TO COMPUTING SYSTEMS. Spring 2018 Lecture 24

Chapter 1 Introduction

Real-Time Multimedia System Analysis: A Breeze in Linux. Whitepaper 1

Process. Heechul Yun. Disclaimer: some slides are adopted from the book authors slides with permission 1

EECS Software Tools. Lab 2 Tutorial: Introduction to UNIX/Linux. Tilemachos Pechlivanoglou

Intel P6 (Bob Colwell s Chip, CMU Alumni) The course that gives CMU its Zip! Memory System Case Studies November 7, 2007.

Scrivere device driver su Linux. Better Embedded 2012 Andrea Righi

LINUX TRACE TOOLS. Understanding the deep roots of new-age kernel instrumentation

ò mm_struct represents an address space in kernel ò task represents a thread in the kernel ò A task points to 0 or 1 mm_structs

COP 4610: Introduction to Operating Systems (Spring 2014) Chapter 3: Process. Zhi Wang Florida State University

CS 261 Fall Mike Lam, Professor. Processes

Lecture 8 Memory Management Strategies (chapter 8)

Scheduling. Don Porter CSE 306

PROCESS MANAGEMENT Operating Systems Design Euiseong Seo

Debugging Kernel without Debugger

1/13/2019 Operating Systems. file:///volumes/users/rasit/desktop/comp3430/coursematerial/slides/03_processes/index.html?

Operating System Design and Implementation Memory Management Part III

Process a program in execution; process execution must progress in sequential fashion. Operating Systems

Process Description and Control. Chapter 3

ECE 7650 Scalable and Secure Internet Services and Architecture ---- A Systems Perspective. Part I: Operating system overview: Processes and threads

ECE 550D Fundamentals of Computer Systems and Engineering. Fall 2017

Chap 4, 5: Process. Dongkun Shin, SKKU

Annotatable Systrace: An Extended Linux ftrace for Tracing a Parallelized Program

Killing Zombies, Working, Sleeping, and Spawning Children

Tracing Lustre. New approach to debugging. ORNL is managed by UT-Battelle for the US Department of Energy

Peeping Tom in the Neighborhood: Keystroke Eavesdropping on Multi-User System

Lecture 4: Mechanism of process execution. Mythili Vutukuru IIT Bombay

Adding Inter-event Capabilities to the Linux Trace Event Subsystem

Developing Real-Time Applications

Measuring the impacts of the Preempt-RT patch

Project 2 Linux Kernel Hacking

Intel P The course that gives CMU its Zip! P6/Linux Memory System November 1, P6 memory system. Review of abbreviations

Agenda Process Concept Process Scheduling Operations on Processes Interprocess Communication 3.2

Interrupts & System Calls

Virtual File System (VFS) Implementation in Linux. Tushar B. Kute,

Processes. Today. Next Time. ! Process concept! Process model! Implementing processes! Multiprocessing once again. ! Scheduling processes

Transcription:

1 Operating System System Call & Debugging Technique 진주영 jjysienna@gmail.com

System Call 2 A way for user-space programs to interact with the kernel System Call enables application programs in user-mode to use functionalities in kernel When one calls system call, system mode will be changed from user-mode to kernel-mode After the job finishes, the mode will be back to user-mode and carry on doing jobs which has been on hold

System Call - example 3

System Call Practice (overview) 4 3 Steps for implementation of your own system call Define a system call Register the system call to SYSCALL table Call it in a user-level application

System Call Practice (1) 5 cd ${KERNEL_SRC_DIR}/kernel vim sysjjy.c vim Makefile

System Call Practice (2) 6 cd ${KERNEL_SRC_DIR}/arch/x86/entry/syscalls vim syscall_64.tbl The index of System Call The name of Pre-defined System Call

System Call Practice (3) 7 cd ${KERNEL_SRC_DIR}/include/linux vim syscalls.h

System Call Practice (4) 8

Debugging Technique printk 9 The function whose job is printing in Kernel The function works similarly to printf() function in C library This function can be called everywhere in kernel We can check logs, printed by printk(), by commands such as /proc/kmsg, printk trace, dmesg /proc/kmsg dmesg

Debugging Technique strace 10 The function shows parameters, returned values and system calls from each command Usage: $ strace command Example1: strace ls Example2: strace./application

Debugging Technique ftrace 11 The function is used to debug or trace the actions in kernel Event tracing (interrupt, scheduling, filesystem, ) Kernel function tracing (all kernel functions, stack usage, ) Latency tracing (wakeup, wakeup_rt, irqsoft, preemptoff, ) /sys/kernel/debug/tracing /sys/kernel/debug/tracing/events

Debugging Technique ftrace 12 example $ cat trace_pipe

Process 13 Processor: Central Processing Unit (CPU) ex. Pentium, Core i7 Program: instruction set to let the computer work Process: executing instance of the program and all context which is produced during executing the instance

Process in Linux 14 ${KERNEL_SRC_DIR}/include/linux/sched.h struct task_struct Process Descriptor Represents a process and maintains the information of a process Current macro You can get the task_struct of current process using current macro in kernel ex. printk( %d, current->pid);

Process Address Space 15 Each process has its own process address space that consists of all virtual addresses that the process is allowed to use The interval of virtual addresses = Memory region

Process Address Space in Linux 16 Memory descriptor(struct mm_struct) includes all information related to the process address space Linux implements a memory region as an object (struct vm_area_struct) struct mm_struct and struct vm_area_struct are defined in ${KERNEL_SRC_DIR}/include/linux/mm_types.h

Process Address Space in Linux 17 Memory descriptor(struct mm_struct) includes all information related to the process address space

Process Address Space in Linux 18

Process Address Space Information in Linux 19 /proc/[pid]/maps Reference: show_map() - ${KERNEL_SRC_DIR}/fs/proc/task_mmu.c Memory Region 1 Memory Region 2 Memory Region 3

Process Address Space Information in Linux 20 /proc/[pid]/smaps Reference: show_smap() - ${KERNEL_SRC_DIR}/fs/proc/task_mmu.c Memory Region 1 Memory Region 2

List Head 21 Doubly linked list is pre-defined in Linux kernel ${KERNEL_SRC_DIR}/include/linux/list.h You don t need to implement linked list Example)

List Head 22 Doubly linked list is pre-defined in Linux kernel ${KERNEL_SRC_DIR}/include/linux/list.h You don t need to implement linked list

Data Structure in Linux kernel There are many data structure to be pre-defined in Linux kernel Example) Doubly Linked List: ${KERNEL_SRC_DIR}/include/linux/list.h Bitmap: ${KERNEL_SRC_DIR}/include/linux/bitmap.h Red-Black Tree: ${KERNEL_SRC_DIR}/include/linux/rbtree.h Radix Tree: ${KERNEL_SRC_DIR}/include/linux/radix-tree.h Hash Table: ${KERNEL_SRC_DIR}/include/linux/hashtable.h