Download presentation
Presentation is loading. Please wait.
1
Review and Q/A
2
Demonstration (1) We use doodle
(2) Half hour for one group, most time in evening (3) I will post the link once I create it
3
Partner? Does everyone has a partner?
If you haven’t sent me your team info, please do it Make sure both of you understand the other’s work
4
Review In general, simulation of a shuttle in the kernel Basic steps
Add three system calls Implement the system call function in a module Create a kernel thread to simulate the shuttle Data structure, Lock, schedule algorithm
5
System calls Follow the steps in the slides and video
Make sure whether is 32 bit or 64 bit Wrapper
6
Wrapper system call What is this STUB thing Used in our module
User space program system call int sys_start_shuttle(void) { if (STUB_start_shuttle) STUB_start_shuttle(); else return -ENOSYS; } What is this STUB thing Used in our module
7
Benefit At this stage, all the work can be done in your module
Does not need to compile the kernel again Use the Makefile example for compiling the module
8
Module Kernel (a giant process) Module
9
When module is loaded STUB_start_shuttle Module Kernel
(a giant process) Module STUB_start_shuttle
10
Module module_init, module_exit In module_init, set function pointers
It will go to the “if” part In module_exit, re-set function pointers It will go to the “else” part
11
Kernel thread One process, multiple threads Module Kernel
(a giant process) Module
12
Create a thread kthread_run(threadfn, data, name)
threadfn — the name of the thread function data — here it is NULL name — whatever you want to name this thread, e.g “ShuttleSimulation”
13
Stop a thread kthread_stop() Where to use it?
Once receive the stop_shuttle() system call After deliver all the passenger In module_exit()
14
In the kernel thread Review previous slides
No more to tell (Don’t hate me :()
15
Data Structure Linked List(Recommend) Use the kernel linked list
Use your own defined list Integers Be careful with array Still need to use lock
16
Lock Where to use lock All the places that need protection
All the places that can be modified by two different processes/threads Passenger information at each terminal
17
Schedule algorithm One-way scan 1,2,3,4,5,1,2,3,4,5,… Two-way scan
1,2,3,4,5,4,3,2,1,2,3,… Greedy Potential issue? Priority-weight (Recommend)
18
Priority Children > Adult > Adult with luggage Close > Far …
19
Reminder Allocate memory for pointers parameter check
correctness check real time <=> clock time
20
Question 1 Can not get a new kernel following the slides and video, tried several times? Start over entirely. See me in my office.
21
Question 2 Can not see my kernel when I boot on machines in lab?
Use fixgrub.sh from website.
22
Question 3 Already used the fixgrub.sh, but still want to make some changes to the kernel? Don’t try to modify the grub yourself. Let me know.
23
Question 4 Can get my new kernel, but system call does not work?
Things to check: 32bit or 64bit, system call number, system call function, log.
24
Question 5 What is wrapper? Where to wrap? How to wrap?
Previous slides. Meet me in my office or in the lab.
25
Question 6 Where to implement the system calls? In your module.
How does the system know the implementation is in the module? Wrapper.
26
Question 7 How to create a kernel thread? Where?
kthread_run(threadfn, data, name). In module_init function, after all the preparation.
27
Question 8 How to stop the thread? Where to stop the thread?
kthread_stop() Either after it deliver the last passenger, or in module_exit function.
28
Question 9 Everytime I start the shuttle(add one passenger, stop the shuttle, do xxx), it crashes, why? Something is wrong in your program. Reboot. Things to look: your code, system log
29
Question 10 Can you debug for me? No.
30
Question 11 Can, or should it be able to add passengers before shuttle started? Yes. Can, or should it be able to add passengers after shuttle stopped?
31
Question 12 Is it possible for a passenger whose initial_terminal and dest_terminal are the same? Yes. One case for you to optimize you schedule algorithm.
32
Question 13 Can I use float/double variables?
No. There is no float/double variables in kernel programming. All variables are either integers or characters.
33
Question 14 Then how do I indicate that the child takes half seat?
(1) Double all the numbers, make the capacity 50, and each type of passengers takes 4, 2, 1. (2) Use odd/even number to determine.
34
Question 15 How to print a decimal number if float/double is not allowed? Use odd/even and manually append the decimal point if necessary.
35
Question 16 May we have some extensions for this project?
Let’s discuss about this.
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.