Fix bugs

It’s common to meet troubles when do a programming work, my program crashed, a bug is detected, or my code isn’t robust enough…

When confronting a problems, how to deal with it?

First of all, quiet down, give a smile to every trouble.

Secondly gather enough information on it, consult to the victim who suffering the problem. The one who holds more information is always superior to others.

And then analyze the problem, decide where the problem most probably be, Make a test plan or check plan carefully.

Finally, just fix it!

There is a word of advice: don’t do anything important when you are not in good condition. Learn to control your feelings, control your temper. Everything will be OK!

新的实验: xargs (moderate) Write a simple version of the UNIX xargs program for xv6: its arguments describe a command to run, it reads lines from the standard input, and it runs the command for each line, appending the line to the command's arguments. Your solution should be in the file user/xargs.c. The following example illustrates xarg's behavior: Note that the command here is "echo bye" and the additional arguments are "hello too", making the command "echo bye hello too", which outputs "bye hello too". $ echo hello too | xargs echo bye bye hello too $ Please note that xargs on UNIX makes an optimization where it will feed more than argument to the command at a time. We don't expect you to make this optimization. To make xargs on UNIX behave the way we want it to for this lab, please run it with the -n option set to 1. For instance $ (echo 1 ; echo 2) | xargs -n 1 echo 1 2 $ Some hints: • Use fork and exec to invoke the command on each line of input. Use wait in the parent to wait for the child to complete the command. • To read individual lines of input, read a character at a time until a newline ('\n') appears. • kernel/param.h declares MAXARG, which may be useful if you need to declare an argv array. • Add the program to UPROGS in Makefile. • Changes to the file system persist across runs of qemu; to get a clean file system run make clean and then make qemu. xargs, find, and grep combine well: $ find . b | xargs grep hello will run "grep hello" on each file named b in the directories below ".". To test your solution for xargs, run the shell script xargstest.sh. Your solution is correct if it produces the following output: $ make qemu ... init: starting sh $ sh < xargstest.sh $ $ $ $ $ $ hello hello hello $ $ You may have to go back and fix bugs in your find program. The output has many $ because the xv6 shell doesn't realize it is processing commands from a file instead of from the console, and prints a $ for each command in the file.
最新发布
11-16
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值