EE512 System Programming Prologue - PowerPoint PPT Presentation

1 / 37
About This Presentation
Title:

EE512 System Programming Prologue

Description:

to install a Minix you can use in future projects. to familiarize yourself ... To understand the Minix kernel structure and play around with the scheduling code ... – PowerPoint PPT presentation

Number of Views:81
Avg rating:3.0/5.0
Slides: 38
Provided by: parkki
Category:

less

Transcript and Presenter's Notes

Title: EE512 System Programming Prologue


1
EE512 System ProgrammingPrologue Project1
T.A Youngwoo Park Computer Engineering Research
Laboratory Korea Advanced Institute Science
Technology Sep 10, 2008
2
Project Schedule
  • OS System calls
  • Process and Threads
  • Scheduling
  • Synchronization
  • Deadlocks
  • Basic Memory Management
  • Paging
  • Page Replacement
  • Segmentation
  • File System
  • I/O

Project 1
Project 2
Project 3
Project 4
3
Overview of Projects
  • Topics covered
  • Project 1 Shell Scheduling
  • Project 2 Synchronization
  • Project 3 File System
  • Project 4 Porting to H/W or Memory Management
  • Policies
  • There will be 4 to 5 design and programming
    assignments.
  • Each project must be done individually.

4
Project 1 - 3
App.
Minix 3.1.2
Minix Image
Kernel
Windows 200 / XP / Vista
Hardware Platform
5
Project 4
App.
Minix 3.1.2
Kernel
Hardware Platform
6
Setting up Minix for Projects
  • Goal
  • to install a Minix you can use in future projects
  • to familiarize yourself with the system
  • to build and (slightly) modify the Minix kernel
  • S/W Requirement
  • Minix Image
  • (http//www.minix3.org/download/).
  • Vmware Server
  • (http//www.vmware.com/download/server/).

7
Setting up Minix for Projects
  • Minix Image Vmware Server

(http//www.minix3.org/download/).
(http//www.vmware.com/download/server/)
8
Creating Virtual Machine
Select "Local host"
New Virtual Machine
9
Creating Virtual Machine
Virtual Machine Setting (Typical)
Virtual Machine Setting (Other)
10
Creating Virtual Machine
Virtual Machine Setting (Name)
Virtual Machine Setting (Network) Change the
Ethernet setting from Bridged .. to NAT
11
Creating Virtual Machine
partitioning the hard drive
VM is generated!!
12
Install Minix
booting Minix from the downloaded image
Power-On the created Virtual Machine
13
Install Minix
Log in as root
Run the setup script
14
Setting Minix
? Keyboard type us-std ? Ethernet card 6 (AMD
LANCE) ? Full Install ? Automatic mode (Enter) ?
Disk Number 0 ? Region Number 0 ? Confirm yes ?
Size of Home 804 ? Block Size 4 KB
  • "shutdown" and boot d0p0

15
Configure the System
Install Utils
"packman" and select "2" Binary packages
sources from CD
Installing
16
Minix usage
  • Editing in Minix
  • Using vim editor
  • Type vim filename
  • i means insert
  • You will edit files after type i
  • After editing files,
  • push esc button wq
  • wq means save quit
  • q means quit
  • q! means compulsory quit
  • You can easily find commands of vi in google or
    naver
  • Edit in your PC and download file
  • But it is inconvenient to debug code

17
How to modify and rebuild the kernel
  • cp -r /usr/src /usr/src.clean
  • Source Backup
  • Using Make
  • Reboot Customized Kernel

18
How to modify and rebuild the kernel
  • Rebuild the kernel
  • Switch to the directory /usr/src/tools
  • Invoke make
  • Check the options to see how a kernel can be
    rebuild and installed
  • Restart Minix Select the third option Start
    custom kernel

19
How to copy source codes (1)
  • In Windows PC
  • Execute ftp program (ex ALFTP)

20
How to copy source codes (2)
  • In Minix
  • Type ftp ip address
  • Username
  • Password
  • Type put filename

21
How to solve network problem
  • If no problem
  • Setting Network IP ifconfig h ipaddress
  • Ex) ifconfig h 143.248.165.202
  • If having problem
  • Change the Ethernet setting from Bridged .. to
    NAT
  • Reference site http//www.minixtips.com/2006/06/
    minix-with-static-ip-address.html

22
  • Project 1

23
Project Overview
  • Project Goal
  • To understand important system calls and
    integrate them into a shell
  • To understand the Minix kernel structure and
    play around with the scheduling code
  • Source Code

Task 2 RT Scheduler
Task 1 Shell
24
TASK? Implement a basic shell (1)
  • Shell A command line interpreter that accept
    input from the user and executes the command that
    are given
  • ex) bash, tcsh, ksh, csh,
  • Assignments
  • shell when shell is ready to accept commands
  • Execute commands
  • ex) ps, ls, cat,
  • Redirect the standard input or standard output
  • Change the direction of standard input output
    using lt, gt
  • ex1) ls l gt aa.txt (Dont display result of ls
    l but store it in aa.txt)
  • ex2) sort lt aa.txt (Display contents of aa.txt
    by sorting)

25
TASK? Implement a basic shell (2)
  • Assignments contd
  • Pipe the output of commands to other commands
  • Connect two processes using
  • Example
  • ps sort gt sort.txt ( ps gt ps.txt, sort
    psout.txt gt sort.txt)
  • Put commands in the background using
  • Implement exit command
  • exit command quit the shell
  • Shell should be called recursively
  • Submission
  • Submit my_shell.c
  • If implementing shell in various codes, submit
    my_shell.tar

26
TASK I Implement a basic shell
  • Flow of a basic shell
  • while(1)
  • fgets() to get inputs
  • Parsing inputs to get what command is
  • pid fork()
  • if(pid -1) error
  • else if (pid 0) child process
  • execvp() execute command
  • else parent process
  • waitpid() wait a child process

27
TASK I Implement a basic shell
  • Implement pipe, redirection, and background
  • Redirection
  • open(), read(), write() system call related with
    file
  • dup() systemcall
  • Pipe
  • pipe() systemcall
  • Background
  • Dont wait child process which is executed in
    background
  • Handle the process when it is finished

28
? Scheduler for a real-time process (1)
2. Tasks
  • Assignments
  • Allows a user process to temporarily become a
    real-time process and scheduled by its own
    priority
  • When running as a real-time process, the process
    should always be scheduled before any other user
    processes
  • However, To have all the system processes (such
    as kernel, server, and device drivers) to take
    precedence over a user task

29
? Scheduler for a real-time process (2)
  • Real-time scheduling
  • To enter this mode, invoke the new system call
    enter_rt
  • Limit the time to run in real-time mode
  • If this time has expired, the process
    automatically is back into normal mode
  • Only allow a single process to run in real-time
    mode
  • Priority scheduling
  • To decide priority, invoke the new system call
    set_priority(int priority)
  • The priority of user process is decreased when
    the process is scheduled
  • The real-time user process has the highest
    priority
  • Submission
  • Submit Sched.patch
  • contains the patch to the Minix kernel to
    implement the scheduler

30
TASK II Scheduler for a real-time process
  • Add a new system call, enter_rt(clock_t period)
  • Refer the material How to Add a New System Call
    for Minix 3
  • Example add printmessage() system call
  • Flow of using a system call

31
TASK II Scheduler for a real-time process
  • Creating a system-call handler
  • /usr/src/servers/pm/table.c
  • /usr/src/servers/pm/proto.h
  • /usr/src/servers/pm/misc.c
  • Compiling the PM server
  • Calling the system-call handler function directly
  • /usr/src/lib/syslib/sys_enter_rt.c
  • /usr/src/include/minix/com.h /usr/include/minix/
    com.h
  • /usr/src/include/minix/syslib.h
    /usr/include/minix/syslib.h

32
TASK II Scheduler for a real-time process
  • Creating a User Library Function
  • Map the system-call number of the handler
    function
  • /usr/src/include/minix/callnr.h
  • /usr/include/minix/callnr.h
  • Define the prototype function in header file
  • /usr/src/include/unistd.h
  • Implement library function
  • /usr/src/lib/posix
  • Implement system call handler
  • /usr/src/kernel/system/do_enter_rt.c
  • /usr/src/kernel/system.h
  • /usr/src/kernel/system.c

33
TASK II Scheduler for a real-time process
  • Process scheduling
  • /usr/src/kernel/proc.c
  • pick_proc() Decide who to run now
  • sched() Determine the scheduling policy
  • /usr/src/kernel/proc.h
  • /usr/src/kernel/glo.h
  • /usr/src/kernel/clock.c
  • Determine when the real-time period of the
    process has expired and need to be put back into
    normal mode

34
Evaluation Criteria
3. Evaluation Criteria
  • Project report
  • Test cases, codes
  • Code Organization
  • Code Readability
  • Comments
  • No errors no warning
  • Assignment 1 30
  • Assignment 2
  • Real-time scheduling 40
  • Priority scheduling 20

35
Submit
4. Submit
  • Due date September 24th (Tue), 2359
  • Collect all modified code and tar
  • tar cvf directory
  • You should explain how to execute your new
    application and kernel and test your submission
  • For code, follow the submission method in handout
  • (!) Your own test code policy should be
    included
  • With project report (studentnumber.doc or .hwp)
  • Studentnumber.zip
  • To ywpark_at_core.kaist.ac.kr
  • Title EE512-Project1 Studentnumber
  • Ex) EE512-Project1 200731xx
  • Penalty
  • If copied, no points
  • Delay 10/day (received time of e-mail)

36
Reference
  • How to add a new system call for Minix3

37
Question
Write a Comment
User Comments (0)
About PowerShow.com