
CMSC321—OperatingSystems
NachosProject2(b):Multiprogrammingi
DueDate:11:59pmWednesday01April2009
ThesespecificationsdescribethesecondsubprojecttocompletephasetwoofNachos.Continuingwith
thespecificationsfromNachosProject2(a),hereistheassignment:
1. TheExec()systemcalldoesnotprovideanywayfortheuserprogramtopassparametersor
argumentstothenewlycreatedaddressspace.UNIXdoesallowthis,forinstance,topassin
commandlineargumentstothenewaddressspace.Implementthisfeature.Theprototypeforthe
newimprovedExecis:
SpaceIdExec(char*name,char*args[]);
Here,argsisavectorofpointerstothestringswhicharetheargumentspassedintothechild
process.ANULLpointerterminatesthevector.Byconvention,args[0]shouldbesettobethename
oftheprograminvoked(i.e.,usuallythelastcomponentintheabsolutefilenameoftheExec‐ed
binary).WhentheExec‐eduserprocessbeginsexecution,themainfunctionisessentiallycalledas
main(intargc,char*argv[])
Theintegerargcistheargumentcount.Sinceargv[0]isalwayssetbyconvention,argcshouldbeat
least1.Thelastprogramargumentwillbedenotedbyargv[argc‐1].
2. Writeashellandsomeutilityprograms.Ashellreadsacommandfromtheuserviatheconsole,
thenrunsthecommandbyinvokingthekernelsystemcallExec().TheUNIXprogrambashisan
exampleofashell.Thereisalreadyasimpleshellinthetestdirectory.Enhanceittodosome
interestingthings.Alsoadapttheshelltoinvokeprogramswithcommandlinearguments(usingthe
Exec()youwroteabove).Testyourshellandsystemcallhandlingbywritingacoupleofutility
programs,suchasUNIXcat,cp,etc.
iFromtheoriginalNachosAssignment#2byTomAnderson;modifiedbyPhilKearnsandlaterJoelHollingsworth,
BarryLawsonandLewisBarnett