2015. 09. 24. Project 2. “Linux Fundamental” procfs By Dong Jae Shin.

Slides:



Advertisements
Similar presentations
This course is designed for system managers/administrators to better understand the SAAZ Desktop and Server Management components Students will learn.
Advertisements

Objectives Overview Define an operating system
Module 8 - Process Management. 1.Linux boot loader 2.Linux boot process 3.Linux processes 4.Linux services 5.Linux top 6.Remember proc ? 7.Linux Device.
Discovering Computers Fundamentals, Third Edition CGS 1000 Introduction to Computers and Technology Fall 2006.
Introduction to Unix (CA263) File System
Exploring the UNIX File System and File Security
1 Web Server Administration Chapter 3 Installing the Server.
GNU/Linux Filesystem 1 st AUT GNU/Linux Festival Computer Engineering & IT Department Bahador Bakhshi.
Lesson 22 – Introduction to Linux Systems Administration.
Guide To UNIX Using Linux Third Edition
SUSE Linux Enterprise Server Administration (Course 3037) Chapter 1 Introduction to Managing the SUSE Linux Enterprise Server.
Linux Filesystem Management
Guide To UNIX Using Linux Fourth Edition
Chapter Three OPERATING SYSTEMS.
1 Web Server Administration Chapter 3 Installing the Server.
Your Interactive Guide to the Digital World Discovering Computers 2012.
Chapter-4 Windows 2000 Professional Win2K Professional provides a very usable interface and was designed for use in the desktop PC. Microsoft server system.
Manage Directories and Files in Linux
Guide to Linux Installation and Administration, 2e1 Chapter 8 Basic Administration Tasks.
CIS 191 – Lesson 2 System Administration. CIS 191 – Lesson 2 System Architecture Component Architecture –The OS provides the simple components from which.
LOGO Linux Installation. Linux Distribution Including shells, libraries, tools, compiler, servers, applications. Redhat, Fedora, Mandrake, SuSE, Debian,
Chapter 9: Networking with Unix and Linux Network+ Guide to Networks Third Edition.
Explain the purpose of an operating system
Chapter 8: Operating Systems and Utility Programs Catherine Gifford Dan Falgares.
Linux Introduction Part 2. Finding Files find “start directory” -name "filename“ Find the file called "filename" on the filesystem starting the search.
A Practical Guide to Fedora and Red Hat Enterprise Linux Unit 8: Installing Software in Linux Chapter 13: Downloading and Installing Software By Fred R.
Installation Overview Lab#2 1Hanin Abdulrahman. Installing Ubuntu Linux is the process of copying operating system files from a CD, DVD, or USB flash.
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.
Guide to Linux Installation and Administration, 2e1 Chapter 10 Managing System Resources.
Chapter Two Exploring the UNIX File System and File Security.
1 Interface Two most common types of interfaces –SCSI: Small Computer Systems Interface (servers and high-performance desktops) –IDE/ATA: Integrated Drive.
1 Objectives Manage and install new file systems.
Agenda Link of the week Use of Virtual Machine Review week one lab assignment This week’s expected outcomes Review next lab assignments Break Out Problems.
Guide to Linux Installation and Administration1 Chapter 4 Running a Linux System.
Kyu Ho Park Sept. 22, Lecture 4 proc file system(procfs) (Project 2 included) Sept.19,4pm.
Operating System What is an Operating System? A program that acts as an intermediary between a user of a computer and the computer hardware. An operating.
Guide To UNIX Using Linux Third Edition Chapter 8: Exploring the UNIX/Linux Utilities.
Manage Directories and Files in Linux. 2 Objectives Understand the Filesystem Hierarchy Standard (FHS) Identify File Types in the Linux System Change.
Manage Directories and Files in Linux Part 2. 2 Identify File Types in the Linux System The file types in Linux referred to as normal files and directories.
PTA Linux Series Copyright Professional Training Academy, CSIS, University of Limerick, 2006 © Workshop V Files and the File System Part B – File System.
OS Project 0 February 25, Outline  Linux Installation  Linux Kernel Compilation  System Call Development  Kernel Modules / 452.
Project 4. “File System Implementation”
Chapter 9: Networking with Unix and Linux. Objectives: Describe the origins and history of the UNIX operating system Identify similarities and differences.
CSC190 Introduction to Computing Operating Systems and Utility Programs.
CSCI 330 UNIX and Network Programming Unit XX: Linux Administration.
LOGO Linux Installation. Linux Distribution Including shells, libraries, tools, compiler, servers, applications. Redhat, Fedora, Mandrake, SuSE, Debian,
CSC414 “Introduction to UNIX/ Linux” Lecture 6. Schedule 1. Introduction to Unix/ Linux 2. Kernel Structure and Device Drivers. 3. System and Storage.
Lecture 02 File and File system. Topics Describe the layout of a Linux file system Display and set paths Describe the most important files, including.
Lab 8 Department of Computer Science and Information Engineering National Taiwan University Lab8 - Root Filesystem 2015/11/10/ 22 1.
Embedded Software Design Week II Linux Intro Linux Kernel.
Guide to Parallel Operating Systems with Windows 7 and Linux Chapter 10 Operating System Management.
Red Hat ® I NTERNET S YS A DMIN Introduction to Linux.
به نام خدای مهربان زبان تخصصی دانشجویان کامپیوتر English for Computer Students درس 3 جوانمرد Ejavanmard.blogfa.com
Advanced Computing Facility Introduction
DISCOVERING COMPUTERS 2018 Digital Technology, Data, and Devices
Operating System Kernel Compilation
Project 4. “File System Implementation”
EE516: Embedded Software Project 1
Lecture 5 proc file system(procfs) (Project 2 included)
OS Homework 1 February 22, 2017.
UBUNTU INSTALLATION
Chapter 2: Operating-System Structures
Basic Commands ls cp ls –l (in detail format) echo ls –a
9 Linux on the Desktop.
Ubuntu Working in Terminal
Operating System Kernel Compilation
Exploring the UNIX File System and File Security
Unix : Introduction and Commands
IS3440 Linux Security Unit 7 Securing the Linux Kernel
bitcurator-access-webtools Quick Start Guide
Presentation transcript:

Project 2. “Linux Fundamental” procfs By Dong Jae Shin

Computer Engineering Research Laboratory Introduction to Projects  Project 1: Setting up Environment for Project  Project 2: Linux Fundamental  Project 3: System Call and Synchronization  Project 4: File System  Project 5: Device Driver for Embedded H/W  Especially, including “BeagleBoard Development” 2

Computer Engineering Research Laboratory Contents  Follow-on Tasks  1. Linux System Administration  2. File System & Software Management  3. Build your own Linux Kernel  Project Tasks  Write a System Monitoring Tools  1. Analyze the given skeleton program (10%)  2. Traverse Process tasklist (20%)  3. per Process Memory Usage (20%)  4. per Process I/O Usage (20%)  5. Process CPU Utilization (10% point Bonus)  Report (30%) Max. 100%

Computer Engineering Research Laboratory Account Management  Add user  # useradd  Delete user  # userdel  Settings per user  /etc/passwd  Change or create user password  # passwd  # passwd username 4

Computer Engineering Research Laboratory File System Management  Add a Virtual Disk  Virtual Machine Settings -> Add -> Hard Disk -> SCSI -> Create a new virtual disk -> 20GB  You need 20GB of free space in your HDD(or SSD) 5

Computer Engineering Research Laboratory File System Management  Disk initialization  Format : Create a empty disk with underlying file system  File system  How store and retrieve data in the storage as a logical unit(file and directory)  File system manages your files in their own structure  We’ll learn file system in our lectures later  ex) ext2, ext3, ext4, FAT, NTFS  Commands  mkfs.XXX : format with XXX file system  We will use ext4 6

Computer Engineering Research Laboratory File System Management  Format disk we added  # ls /dev/sd*  /dev/sdb is our new disk  # mkfs.ext4 /dev/sdb  Mount new disk  # cd /root && mkdir mnt  # mount /dev/sdb./mnt  Check mounted disk partition  # df -hT  Unmount disk  # umount /dev/sdb  we can also use directory name  # umount /root/mnt 7 # gnome-disks

Computer Engineering Research Laboratory Software Install and Uninstall  Ubuntu use “Advanced Packaging Tool”  Install : apt-get install package-name  ex) # apt-get install vim  Uninstall : apt-get remove package-name  Search : apt-cache search search-string  ex) # apt-cache search gcc  Redhat distribution family use “Yellowdog Updater Modified”  # yum install vim  # yum erase vim  # yum search gcc 8

Computer Engineering Research Laboratory Kernel  Kernel  Core of Operating System 9 User ProgramUser InterfaceSystem Calls Memory Management Process Management I/O File System NetworkSecurity Device Drivers Hardware User Space Kernel Space

Computer Engineering Research Laboratory Linux Distributions  Linux Distributions  Combine & Maintain features 10 Linux Kernel System Software -Compiler -Libraries -User Interface (GUI, CLI) User Program -Office -Database -Browser -Server Program Libraries & Android Runtime Apps -Camera -Browser -SMS Application Framework

Computer Engineering Research Laboratory Linux Kernel Download  Download Linux Kernel Source Code   or tar.xzhttp://core.kaist.ac.kr/~EE516/resources/linux tar.xz 11

Computer Engineering Research Laboratory Compile Linux Kernel  change to root account  # su - root  Install libraries for compile  # sudo apt-get install build-essential libncurses5-dev  Unzip  # cd /root/mnt  # tar -xvf linux tar.gz  # cd linux  Copy original configuration file  # cp /boot/config generic.config./ 12 Kernel compile needs large disk space about 11GB. We can use new disk we already mounted.

Computer Engineering Research Laboratory Compile Linux Kernel  Kernel build configuration  # make menuconfig  just save & exit (we already copy.config file) 13

Computer Engineering Research Laboratory Compile Linux Kernel  Linux Kernel Build  Check your # of cores  # cat /proc/cpuinfo |grep processor  Build with multiple processors  if you have 4 processors  # make -j4  It takes long time  Copy compiled kernel & modules  # make modules_install  # make install  Check /boot directory  14

Computer Engineering Research Laboratory Booting with new Kernel  # reboot  Keep “shift key down” while rebooting!  Boot menu -> Advanced options -> Select  Check your new kernel  # uname -a Compile Time of Kernel

Computer Engineering Research Laboratory (1)Kernel Debugging  Print Kernel-level Message  printk  Kernel version of printf  usage) printk(“%s %d %lu”, str, i, j );  Kernel Log Message  tail -f /var/log/kern.log  See also (optional)  for advanced debugging  procfs

Computer Engineering Research Laboratory (2)/proc File System  /proc  a special file system which displays the present of the system  pseudo and virtual file system which resides in the RAM  provides a method of communication between kernel space and user space  Various information provided by proc  proc.txt proc.txt 17 procfs

Computer Engineering Research Laboratory (3)/proc File System  CPU Information  cat /proc/cpuinfo 18  Main Memory Information  cat /proc/meminfo Kernel Debugging

Computer Engineering Research Laboratory (4)Create a proc entry  Download Skeleton Files  # wget  # wget ple.c ple.c  Compile  # make  Useful ref)  procfs

Computer Engineering Research Laboratory (5)Test proc entry  Kernel Log  # tail -f /var/log/kern.log  Insert Module  insmod proc_sample.ko  Write Proc File  # echo blahblah > /proc/proc_sample  Read Proc File  # cat /proc/proc_sample  Remove Module  # rmmod proc_sample 20 procfs

Computer Engineering Research Laboratory Project Tasks  Make a System Monitoring Tools  System monitoring is an important job especially on the embedded system  Low computing power, Less memory, Limited resources  Monitoring tools  top, ps, netstat, gnome-system-monitor  Tasks  1. Analyze the given skeleton of promon.c.(10%)  2. Traverse Process tasklist (20%)  3. per Process Memory Usage (20%)  4. per Process I/O Usage (20%)  5. Process CPU Utilization (10% point Bonus Task)  Report  (30%) 21 Project Tasks

Computer Engineering Research Laboratory Task 1  Analyze the given skeleton of proc_sample.c  Find the functions that you do not know and explain the operations of those functions referring to references and Google. 22

Computer Engineering Research Laboratory Task2. Traverse Task List  Every Linux Tasks are managed by doubly linked list 23  Print every task’s PID and Process Name in your proc file system  Textbook Chapter 3. Understanding the Linux Kernel, 3 rd  free e-book version : ding.pdf ding.pdf Project Tasks

Computer Engineering Research Laboratory task_struct  task_struct (=Process Descriptor) 24  KERNEL/include/linux/sch ed.h  Useful materials : Textbook Chapter 3. of ULK Project Tasks

Computer Engineering Research Laboratory task_struct 25 ………

Computer Engineering Research Laboratory Task3. Memory Usage  Memory Mapping  RSS : Resident Set Size  VIRT : Virtual Memory Size  Print every task’s VIRT and RSS Memory Size 26 VIRT RSS VIRT Project Tasks Hint) KERNEL/include/linux/mm_types.h struct mm_struct { … unsigned long total_vm; struct mm_rss_stat rss_stat; … }

Computer Engineering Research Laboratory Task3. Memory Usage 27 Project Tasks task_struct … *active_mm … *active_mm … mm_struct … total_vm … rss_stat … total_vm … rss_stat include/linux/mm_types.h VIRT Memory rss_stat.count[MM_FILEPAGES] rss_stat.count[MM_ANONPAGES] RSS Memory MM_FILEPAGES : Type of File Mapped Page MM_ANONPAGES : Type of Anonymous Page (Stack, Heap …) include/linux/sched.h

Computer Engineering Research Laboratory Task4. Process I/O Stat  I/O Stat is stored in struct task_io_accounting  include/linux/task_io_accounting.h  Hint)  # cat /proc/PID/io  rchar : read bytes by process  wchar : written bytes by process  syscr : # of read system calls  syscw : # of write system calls  read_bytes : read bytes from disk  write_bytes : written bytes to disk 28 write_bytesread_bytes Disk Cache in DRAM Process wcharrchar Project Tasks

Computer Engineering Research Laboratory Task4. Process I/O Stat  Hint 1)  fs/proc/base.c  print function of /proc/pid/io  Hint 2)  include/linux/task_io_accounting_ops.h  task_io_accounting_add() function  Hint 3)  task_struct->ioac  task_struct->signal->ioac  for each thread  task_struct->ioac 29 Project Tasks write_bytesread_bytes Disk Cache in DRAM Process wcharrchar

Computer Engineering Research Laboratory Task5. CPU Utilization  “top” command  shows the CPU utilization per process 30  Challenging Task (Bonus Point 10%)  Kernel manages CPU ticks consumed by each process in struct task_cputime  in include/linux/sched.h  utime + stime 5. Project Tasks

Computer Engineering Research Laboratory Example of Output Project Tasks

Computer Engineering Research Laboratory Check your results  Check the correctness of your results  Task 2.  # ps -ef  Task 3.  # top -b -n 1  Task 4.  Browser is a good test case (# firefox)  Get pid  ps -ef |grep firefox  # cat /proc/PID/io  Task 5.  # top Project Tasks

Computer Engineering Research Laboratory Problems  Problem1.  Describe similarity and difference Process and LWP(Lightweight Process) in the Linux  from the view point of task_struct, PID management, data sharing and scheduling  Problem2.  Describe why we use copy_to_user(), copy_from_user() functions in the proc file system 33

Computer Engineering Research Laboratory Submission  Contents  Source Code  Report Project Tasks1~5  Key point of your Source Code  Final Screenshots  Page Limit : about 5 pages for Project Tasks1~5. (except figures)  Submission  Due Date : Oct. 8, PM 23:59  Delay Penalty  10%/day (AM 00:00)   [EE516 Project2] student_number.zip  (various compression format is allowed)