首页
网站开发
桌面应用
管理软件
微信开发
App开发
嵌入式软件
工具软件
数据采集与分析
其他
首页
>
> 详细
CSc 360编程辅导、C++程序辅导
项目预算:
开发周期:
发布时间:
要求地区:
1 CSc 360: Operating Systems
2 (Fall 2020)
Programming Assignment 1
P1: A Process Manager (PMan)
3
4 Spec Out: Sept. 13, 2021
5 Code Due: Oct. 4, 2021 (23:55 pm)
6 1 Goals
7 This assignment is designed to help you:
8 1. get familiar with C programming,
9 2. get familiar with system calls related to process management,
10 3. get familiar with the process control block (PCB).
11 You are required to implement your solution in C (other languages are not allowed). Your work
12 will be tested on linux.csc.uvic.ca.
13
14 Note: linux.csc.uvic.ca is a particular machine at the UVic Department of Computer Sci-
15 ence. It does not mean “any Linux machine” at UVic. Even more importantly, it does not mean any
16 “Unix-like” machine, such as a Mac OS X machine—many students have developed their programs
17 for their Mac OS X laptops only to find that their code works differently on linux.csc.uvic.ca
18 resulting in a substantial loss of marks.
19 You can remote access linux.csc.uvic.ca by ssh username@linux.csc.uvic.ca. SSH clients
20 are available for a wide variety of operating systems including Linux, Mac OS and Windows.
21 Be sure to study the man pages for the various systems calls and functions suggested in this
22 assignment. The system calls are in Section 2 of the man pages, so you should type (for example):
23 ✩ man 2 waitpid
24 2 Schedule
25 In order to help you finish this programming assignment on time, the schedule of this assignment
26 has been synchronized with both the lectures and the tutorials. There are three tutorials arranged
27 during the course of this assignment.
1
Tutorial No. Tutorial Milestones
First system programming in C, P1 spec go-through, design hints design and code skeleton
Second more on system programming and testing alpha code done
Third final testing and last-minute help final deliverable
28 3 Requirements
29 3.1 Prompt for user input
30 Your PMan needs to show the prompt for user input. For example, when you run PMan by type in
31 linux.csc.uvic.ca:/home/user✩ ./PMan
32 It prompts
33 PMan: >
34 for user input.
35 3.2 Background Execution of Programs
36 PMan allows a program to be started in the background—that is, the program is running, but PMan
37 continues to accept input from the user. You will implement a simplified version of background
38 execution that supports executing processes in the background.
39 If the user types: bg foo, your PMan will start the program foo in the background. That is,
40 the program foo will execute and PMan will also continue to execute and give the prompt to accept
41 more commands.
42 The command bglist will have PMan display a list of all the programs currently executing in
43 the background, e.g.,:
44 123: /home/user/a1/foo
45 456: /home/user/a1/foo
46 Total background jobs: 2
47 In this case, there are 2 background jobs, both running the program foo, the first one with
48 process ID 123 and the second one with 456.
49 Your PMan needs to support the following commands:
50 1. The command bgkill pid will send the TERM signal to the job with process ID pid to terminate
51 that job.
52 2. The command bgstop pid will send the STOP signal to the job pid to stop (temporarily) that
53 job.
54 3. The command bgstart pid will send the CONT signal to the job pid to re-start that job (which
55 has been previously stopped).
56 See the man page for the kill() system call for details.
57 Your PMan must indicate to the user when background jobs have terminated. Read the man
58 page for the waitpid() system call. You are suggested to use the WNOHANG option.
2
59 3.3 Status of Process
60 Your PMan needs to support a command pstat pid to list the following information related to
61 process pid, where pid is the Process ID.
62 1. comm : The filename of the executable, in parentheses. This is visible whether or not the
63 executable is swapped out.
64 2. state : One of the following characters, indicating process state: R (Running), S (Sleeping
65 in an interruptible wait), D (Waiting in uninterruptible disk sleep), Z (Zombie), T (Stopped
66 (on a signal) or (before Linux 2.6.33) trace stopped ), t (Tracing stop (Linux 2.6.33 onward)),
67 W (Paging (only before Linux 2.6.0)), X (Dead (from Linux 2.6.0 onward)), x (Dead (Linux
68 2.6.33 to 3.13 only)), K (Wakekill (Linux 2.6.33 to 3.13 only)), W (Waking (Linux 2.6.33 to
69 3.13 only)), P (Parked (Linux 3.9 to 3.13 only)).
70 3. utime: Amount of time that this process has been scheduled in user mode, measured in clock
71 ticks (divide by sysconf( SC CLK TCK)). This includes guest time, guest time (time spent
72 running a virtual CPU, see below), so that applications that are not aware of the guest time
73 field do not lose that time from their calculations.
74 4. stime: Amount of time that this process has been scheduled in kernel mode, measured in
75 clock ticks (divide by sysconf( SC CLK TCK)).
76 5. rss: Resident Set Size: number of pages the process has in real memory. This is just the pages
77 which count toward text, data, or stack space. This does not include pages which have not
78 been demand-loaded in, or which are swapped out.
79 6. voluntary ctxt switches: Number of voluntary context switches (since Linux 2.6.23).
80 7. nonvoluntary ctxt switches: Number of involuntary context switches (since Linux 2.6.23).
81 If process pid does not exist, PMan returns an error like:
82 Error: Process 1245 does not exist.
83 In the above example, 1245 is the pid value.
84 To summarize, your PMan should support the following commands: bg, bglist, bgkill,
85 bgstop, bgstart, and pstat. If the user types an unrecognized command, an error message is
86 given by PMan, e.g.,
87 PMan:> ttest
88 PMan:> ttest: command not found
89 4 Deliveries and Marking Scheme
90 For your final submission of each assignment you are required to submit your source code to connex
91 dropbox. You should include a readme file to tell TA how to compile and run your code. TAs are not
92 supposed to fix the bugs, either in your source code or in your make file. If following your readme
93 file, the TAs cannot compile and run your code, you may get a zero mark for the assignment.
94 The marking scheme is as follows:
3
Components Weight
Make file 5
Error handling 10
bg 10
bglist 10
bgkill 10
bgstop 10
bgstart 15
pstat 20
Code style 5
Readme.txt 5
Total Weight 100
95
96 5 Odds and Ends
97 5.1 Implementation Hints
98 1. Use fork() and execvp() so that the parent process accepts user input and the child process
99 executes arbitrary commands.
100 2. Use a data structure (e.g., a linked list) to record the background processes.
101 3. Use the \proc pseudo-file system to find out the information required by pstat. Note that
102 \proc is not a real file system, because all files have a size zero. The files just include a pointer
103 to process control block (PCB) in the OS kernel. Due to this reason, never try to write
104 anything into \proc!
105 5.2 Warning
106 Since you will use fork() in your assignment, it is important that you do not create a fork()
107 bomb, which easily eats up all the pid resources allocated to you. If this happens, you cannot log
108 into your account any more, even from a different machine. Both the instructor and the TAs cannot
109 help you out. You have to go to IT support asking them to kill your buggy process. Clearly, IT
110 support will not be happy if many students ask for such a help.
111 To avoid the mishap, you MUST use ulimit -u in bash to find out the default max number
112 of user processes allocated to you (it is normally 50), and reduce this number to a safe value. For
113 instance, if the default max number of user processes is 50, you can use
114 % ulimit -u 35
115 to reduce this number to 35. Therefore, even if your code has a bug and has created a fork()
116 bomb, you still have unused 15 processes left and you can log in from a different machine to kill
117 the buggy process.
118 Please take this warning seriously!
4
119 5.3 Compilation
120 You’ve been provided with a Makefile that builds the sample code (in p1s.tar.gz). It takes care
121 of linking-in the GNU readline library for you. The sample code shows you how to use readline()
122 to get input from the user, only if you choose to use the readline library.
123 5.4 Helper Programs
124 5.4.1 inf.c
125 This program takes two parameters:
126 tag: a single word which is printed repeatedly
127 interval: the interval, in seconds, between two printings of the tag
128 The purpose of this program is to help you with debugging background processes. It acts a trivial
129 background process, whose presence can be “felt” since it prints a tag (specified by you) every few
130 seconds (as specified by you). This program takes a tag so that even when multiple instances of it
131 are executing, you can tell the difference between each instance.
132 This program considerably simplifies the programming of PMan which deals with re-starting,
133 stopping, and killing programs.
134 5.4.2 args.c
135 This is a very trivial program which prints out a list of all arguments passed to it.
136 This program is provided so that you can verify that your PMan passes all arguments supplied
137 on the command line—often, people have off-by-1 errors in their code and pass one argument less.
138 5.5 Code Quality
139 We cannot specify completely the coding style that we would like to see but it includes the following:
140 1. Proper decomposition of a program into subroutines (and multiple source code files when
141 necessary)—A 500 line program as a single routine won’t suffice.
142 2. Comment—judiciously, but not profusely. Comments also serve to help a marker, in addition
143 to yourself. To further elaborate:
144 (a) Your favorite quote from Star Wars or Douglas Adams’ Hitch-hiker’s Guide to the Galaxy
145 does not count as comments. In fact, they simply count as anti-comments, and will result
146 in a loss of marks.
147 (b) Comment your code in English. It is the official language of this university.
148 3. Proper variable names—leia is not a good variable name, it never was and never will be.
149 4. Small number of global variables, if any. Most programs need a very small number of global
150 variables, if any. (If you have a global variable named temp, think again.)
151 5. The return values from all system calls and function calls listed in the assignment
152 specification should be checked and all values should be dealt with appropriately.
5
153 5.6 Plagiarism
154 This assignment is to be done individually. You are encouraged to discuss the design of your solution
155 with your classmates, but each person must implement their own assignment.
156 Your markers will submit the code to an automated plagiarism detection program.
157 We add archived solutions from previous semesters (a few years worth) to the plagia-
158 rism detector, in order to catch “recycled” solutions.
159
160 The End
6
软件开发、广告设计客服
QQ:99515681
邮箱:99515681@qq.com
工作时间:8:00-23:00
微信:codinghelp
热点项目
更多
代做ceng0013 design of a pro...
2024-11-13
代做mech4880 refrigeration a...
2024-11-13
代做mcd1350: media studies a...
2024-11-13
代写fint b338f (autumn 2024)...
2024-11-13
代做engd3000 design of tunab...
2024-11-13
代做n1611 financial economet...
2024-11-13
代做econ 2331: economic and ...
2024-11-13
代做cs770/870 assignment 8代...
2024-11-13
代写amath 481/581 autumn qua...
2024-11-13
代做ccc8013 the process of s...
2024-11-13
代写csit040 – modern comput...
2024-11-13
代写econ 2070: introduc2on t...
2024-11-13
代写cct260, project 2 person...
2024-11-13
热点标签
mktg2509
csci 2600
38170
lng302
csse3010
phas3226
77938
arch1162
engn4536/engn6536
acx5903
comp151101
phl245
cse12
comp9312
stat3016/6016
phas0038
comp2140
6qqmb312
xjco3011
rest0005
ematm0051
5qqmn219
lubs5062m
eee8155
cege0100
eap033
artd1109
mat246
etc3430
ecmm462
mis102
inft6800
ddes9903
comp6521
comp9517
comp3331/9331
comp4337
comp6008
comp9414
bu.231.790.81
man00150m
csb352h
math1041
eengm4100
isys1002
08
6057cem
mktg3504
mthm036
mtrx1701
mth3241
eeee3086
cmp-7038b
cmp-7000a
ints4010
econ2151
infs5710
fins5516
fin3309
fins5510
gsoe9340
math2007
math2036
soee5010
mark3088
infs3605
elec9714
comp2271
ma214
comp2211
infs3604
600426
sit254
acct3091
bbt405
msin0116
com107/com113
mark5826
sit120
comp9021
eco2101
eeen40700
cs253
ece3114
ecmm447
chns3000
math377
itd102
comp9444
comp(2041|9044)
econ0060
econ7230
mgt001371
ecs-323
cs6250
mgdi60012
mdia2012
comm221001
comm5000
ma1008
engl642
econ241
com333
math367
mis201
nbs-7041x
meek16104
econ2003
comm1190
mbas902
comp-1027
dpst1091
comp7315
eppd1033
m06
ee3025
msci231
bb113/bbs1063
fc709
comp3425
comp9417
econ42915
cb9101
math1102e
chme0017
fc307
mkt60104
5522usst
litr1-uc6201.200
ee1102
cosc2803
math39512
omp9727
int2067/int5051
bsb151
mgt253
fc021
babs2202
mis2002s
phya21
18-213
cege0012
mdia1002
math38032
mech5125
07
cisc102
mgx3110
cs240
11175
fin3020s
eco3420
ictten622
comp9727
cpt111
de114102d
mgm320h5s
bafi1019
math21112
efim20036
mn-3503
fins5568
110.807
bcpm000028
info6030
bma0092
bcpm0054
math20212
ce335
cs365
cenv6141
ftec5580
math2010
ec3450
comm1170
ecmt1010
csci-ua.0480-003
econ12-200
ib3960
ectb60h3f
cs247—assignment
tk3163
ics3u
ib3j80
comp20008
comp9334
eppd1063
acct2343
cct109
isys1055/3412
math350-real
math2014
eec180
stat141b
econ2101
msinm014/msing014/msing014b
fit2004
comp643
bu1002
cm2030
联系我们
- QQ: 9951568
© 2021
www.rj363.com
软件定制开发网!