homework there will be 4 homework assignments there will be 4 homework assignments they will each be...

22
Homework Homework There will be 4 homework assignments There will be 4 homework assignments They will each be graded 0-100+ (There will be bonus) They will each be graded 0-100+ (There will be bonus) Total weight = 55% (total weight of test = 55%) Total weight = 55% (total weight of test = 55%) Homework can be done in groups Homework can be done in groups Each group must meet the ex. Checker and defend their work. the Each group must meet the ex. Checker and defend their work. the grade of the group will be the grade of it’s worst member! grade of the group will be the grade of it’s worst member! The kernel homework will be checked on a computer with VMWare that The kernel homework will be checked on a computer with VMWare that you should download and verify. The User space code will be checked you should download and verify. The User space code will be checked on VMWare on VMWare No rechecks for code that doesn’t run No rechecks for code that doesn’t run !!! !!! No points will be deducted on code quality (unless we see real No points will be deducted on code quality (unless we see real atrocities) but points will be deducted if the ex doesn’t work as atrocities) but points will be deducted if the ex doesn’t work as supposed to or use the OS incorrectly. supposed to or use the OS incorrectly.

Upload: donna-tucker

Post on 28-Dec-2015

224 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Homework There will be 4 homework assignments There will be 4 homework assignments They will each be graded 0-100+ (There will be bonus) They will each

HomeworkHomework

There will be 4 homework assignments There will be 4 homework assignments

They will each be graded 0-100+ (There will be bonus)They will each be graded 0-100+ (There will be bonus)

Total weight = 55% (total weight of test = 55%)Total weight = 55% (total weight of test = 55%)

Homework can be done in groupsHomework can be done in groups

Each group must meet the ex. Checker and defend their work. the Each group must meet the ex. Checker and defend their work. the grade of the group will be the grade of it’s worst member!grade of the group will be the grade of it’s worst member!

The kernel homework will be checked on a computer with VMWare The kernel homework will be checked on a computer with VMWare that you should download and verify. The User space code will be that you should download and verify. The User space code will be checked on VMWare checked on VMWare

No rechecks for code that doesn’t runNo rechecks for code that doesn’t run!!!!!!

No points will be deducted on code quality (unless we see real No points will be deducted on code quality (unless we see real atrocities) but points will be deducted if the ex doesn’t work as atrocities) but points will be deducted if the ex doesn’t work as supposed to or use the OS incorrectly. supposed to or use the OS incorrectly.

Page 2: Homework There will be 4 homework assignments There will be 4 homework assignments They will each be graded 0-100+ (There will be bonus) They will each

Defending homeworkDefending homework

The main reason is policy – since the The main reason is policy – since the homework affect grade to such extent it homework affect grade to such extent it cannot be allowed without oral exam. cannot be allowed without oral exam.

This method have proven to be very This method have proven to be very effective in ensuring students success on effective in ensuring students success on the final test.the final test.

It cannot be changed not even if you work It cannot be changed not even if you work alone.alone.

Page 3: Homework There will be 4 homework assignments There will be 4 homework assignments They will each be graded 0-100+ (There will be bonus) They will each

What questions do we ask What questions do we ask when you defend your code?when you defend your code?

50 questions are prepared for each ex. 3 50 questions are prepared for each ex. 3 random questions per student.random questions per student.

Questions type : show me where you <do Questions type : show me where you <do something>, what does <this> line do? Why something>, what does <this> line do? Why did you add this check etc.did you add this check etc.

No student that worked on the ex. Should No student that worked on the ex. Should fail. But it is almost impossible to “fake”. fail. But it is almost impossible to “fake”. (so please DO your homework)(so please DO your homework)

Page 4: Homework There will be 4 homework assignments There will be 4 homework assignments They will each be graded 0-100+ (There will be bonus) They will each

Strict timetable policyStrict timetable policy

In order to minimize hassle for you, we will give In order to minimize hassle for you, we will give oral exam on the homework within 1 week of dead oral exam on the homework within 1 week of dead line.line.

That means we need to schedule a room, invite That means we need to schedule a room, invite checker and grade everything within very short checker and grade everything within very short time!time!

Since we do all that – we believe students should Since we do all that – we believe students should be ready. By not submitting homework in time you be ready. By not submitting homework in time you delay our checking and ruin our system.delay our checking and ruin our system.

We are also firm believers on strict timelines.We are also firm believers on strict timelines.

Page 5: Homework There will be 4 homework assignments There will be 4 homework assignments They will each be graded 0-100+ (There will be bonus) They will each

Using LinuxUsing Linux

The good but hard way – install on your computer. (Do this if The good but hard way – install on your computer. (Do this if you know what you are doing and at your own risk we cannot you know what you are doing and at your own risk we cannot and will not provide support if your computer fail)and will not provide support if your computer fail)

The also possible way – Download VM Player from The also possible way – Download VM Player from VMWare.com (free) and use it with our vmware. VMWare.com (free) and use it with our vmware.

We will distribute VMWare machine you can work on. (MTA – We will distribute VMWare machine you can work on. (MTA – via library, TAU – Amir’s door) It will also be available on class via library, TAU – Amir’s door) It will also be available on class on MTA.on MTA.

The not recommended waysThe not recommended ways Using only user mode linux on TAU.Using only user mode linux on TAU. Using your own different linux distributionUsing your own different linux distribution Using another UNIXUsing another UNIX ETC… all those methods are at your own risks. Should anything fail, ETC… all those methods are at your own risks. Should anything fail,

you will be sole responsible due to all incompatibilities. you will be sole responsible due to all incompatibilities.

Page 6: Homework There will be 4 homework assignments There will be 4 homework assignments They will each be graded 0-100+ (There will be bonus) They will each

Using Linux under Using Linux under VMPlayerVMPlayer

Simulates computer inside your computer.Simulates computer inside your computer.

Slower then real PC but good enough for us.Slower then real PC but good enough for us.

For most practical purposes can be treated as a For most practical purposes can be treated as a real computer with real OS. (certainly for this real computer with real OS. (certainly for this course)course)

Root password : passwordRoot password : password

User password : userUser password : user

Download from www.scipio.org/Courses/OS_CourseDownload from www.scipio.org/Courses/OS_Course

Page 7: Homework There will be 4 homework assignments There will be 4 homework assignments They will each be graded 0-100+ (There will be bonus) They will each

User vs RootUser vs Root

User – can run programsUser – can run programs

Root – can run system programs. Administrator of system Root – can run system programs. Administrator of system (usually owner or owner’s employee)(usually owner or owner’s employee)

User – can hardly cause damages.User – can hardly cause damages.

Root – prune to damages.Root – prune to damages.

Root – can use low-level system resources (such as row Root – can use low-level system resources (such as row sockets) and setup kernel modulessockets) and setup kernel modules

Most of the time we work as userMost of the time we work as user

Sometimes (rarely) we work as root. When coding stuff on the Sometimes (rarely) we work as root. When coding stuff on the kernel or running administration commands. In Ubunto we kernel or running administration commands. In Ubunto we login as user and sudo(1) when we need root accesslogin as user and sudo(1) when we need root access

Page 8: Homework There will be 4 homework assignments There will be 4 homework assignments They will each be graded 0-100+ (There will be bonus) They will each

Assumed knowledgeAssumed knowledge

We assume you know how to code in C in KR Level.We assume you know how to code in C in KR Level. We assume you know how to handle stringsWe assume you know how to handle strings We assume you know how to do basic mathWe assume you know how to do basic math We assume you know how to allocate and free We assume you know how to allocate and free

memorymemory We assume you know how to create functions and We assume you know how to create functions and

use recursion, library functions and function pointersuse recursion, library functions and function pointers We assume you know how to open files and foldersWe assume you know how to open files and folders We assume you know what editor, compiler, debugger We assume you know what editor, compiler, debugger

and Make (build) is.and Make (build) is.

Page 9: Homework There will be 4 homework assignments There will be 4 homework assignments They will each be graded 0-100+ (There will be bonus) They will each

Using LinuxUsing Linux

There are many manuals on the net. (Try – UNIX There are many manuals on the net. (Try – UNIX is a 4 letter word and vi is 2 letter abbreviation)is a 4 letter word and vi is 2 letter abbreviation)

There is also a readme that comes with your VMThere is also a readme that comes with your VM

Some basic commandsSome basic commands mkdir, rmdir, cd – just like MS-DOSmkdir, rmdir, cd – just like MS-DOS ls – list files (dir)ls – list files (dir) vi – Text editorvi – Text editor cp – copycp – copy rm – remove (delete)rm – remove (delete)

Page 10: Homework There will be 4 homework assignments There will be 4 homework assignments They will each be graded 0-100+ (There will be bonus) They will each

Coding and programming Coding and programming in Linuxin Linux

First thing we need to do is edit a source file. First thing we need to do is edit a source file. (which is basically a text file) (which is basically a text file)

Create a source file in your favorite editor (I use vi.)Create a source file in your favorite editor (I use vi.)

Compile using gcc –c “source file” –o “object file”Compile using gcc –c “source file” –o “object file”

Link using gcc <objects> -o <binary>Link using gcc <objects> -o <binary>

This process can be automated by using MakefileThis process can be automated by using Makefile

Run using ./<binary> (we don’t have . In the default Run using ./<binary> (we don’t have . In the default search path)search path)

Page 11: Homework There will be 4 homework assignments There will be 4 homework assignments They will each be graded 0-100+ (There will be bonus) They will each

Sample program – compile Sample program – compile and runand run

Macintosh:~ scipio$ vi hello.cMacintosh:~ scipio$ vi hello.c

Macintosh:~ scipio$ gcc -c hello.c -o hello.oMacintosh:~ scipio$ gcc -c hello.c -o hello.o

Macintosh:~ scipio$ gcc hello.o -o helloMacintosh:~ scipio$ gcc hello.o -o hello

Macintosh:~ scipio$ ./helloMacintosh:~ scipio$ ./hello

hello worldhello world

Page 12: Homework There will be 4 homework assignments There will be 4 homework assignments They will each be graded 0-100+ (There will be bonus) They will each

Source of hello.cSource of hello.c

#include <stdio.h>#include <stdio.h>

int main(int argc, char * argv[])int main(int argc, char * argv[])

{{

printf("hello world\n");printf("hello world\n");

return 0;return 0;

}}

Page 13: Homework There will be 4 homework assignments There will be 4 homework assignments They will each be graded 0-100+ (There will be bonus) They will each

MakefileMakefile

Makefile (same as project file in other Makefile (same as project file in other environments) is a simple way to automate environments) is a simple way to automate build processbuild process

Makefile works like that…Makefile works like that… <Target> : <requirement><Target> : <requirement> <tab> <how to produce><tab> <how to produce> <next target><next target>

For example for hello world the make can For example for hello world the make can look likelook like

Page 14: Homework There will be 4 homework assignments There will be 4 homework assignments They will each be graded 0-100+ (There will be bonus) They will each

MakefileMakefile

all : helloall : hello

hello : hello.ohello : hello.o

gcc hello.o -o hellogcc hello.o -o hello

hello.o : hello.chello.o : hello.c

gcc -g -c hello.c -o hello.ogcc -g -c hello.c -o hello.o

Page 15: Homework There will be 4 homework assignments There will be 4 homework assignments They will each be graded 0-100+ (There will be bonus) They will each

Using makeUsing make

Macintosh:~ scipio$ makeMacintosh:~ scipio$ make

gcc -g -c hello.c -o hello.ogcc -g -c hello.c -o hello.o

gcc hello.o -o hellogcc hello.o -o hello

Page 16: Homework There will be 4 homework assignments There will be 4 homework assignments They will each be graded 0-100+ (There will be bonus) They will each

debuggingdebugging

The Linux debugger is gdb The Linux debugger is gdb

You must compile with –g switch to include You must compile with –g switch to include debug info (same as debug/release build in other debug info (same as debug/release build in other environments)environments)

You can use gdb to trace (step, step into, next) You can use gdb to trace (step, step into, next) your programs. Gdb has a graphical front end – your programs. Gdb has a graphical front end – dddddd

Usually though you will just examine core dump. Usually though you will just examine core dump. (core is what your program leaves when it (core is what your program leaves when it crashes)crashes)

Page 17: Homework There will be 4 homework assignments There will be 4 homework assignments They will each be graded 0-100+ (There will be bonus) They will each

Crash.cCrash.c

int main()int main()

{{

int i=5;int i=5;

int j=0;int j=0;

int k=i/j;int k=i/j;

}}

Page 18: Homework There will be 4 homework assignments There will be 4 homework assignments They will each be graded 0-100+ (There will be bonus) They will each

Using UNIX to debug…Using UNIX to debug…

ulimit –c 999999ulimit –c 999999

gcc –g crash.c –o crashgcc –g crash.c –o crash

./crash./crash

gdb –c core ./crashgdb –c core ./crash

……

Program received signal EXC_ARITHMETIC, Arithmetic Program received signal EXC_ARITHMETIC, Arithmetic exception.exception.

0x00001ff3 in main () at crash.c:50x00001ff3 in main () at crash.c:5

55 int k=i/j;int k=i/j;

Page 19: Homework There will be 4 homework assignments There will be 4 homework assignments They will each be graded 0-100+ (There will be bonus) They will each

More optionsMore options

Gcc and gdb has lots more options, while Gcc and gdb has lots more options, while Make is fully programmable environment.Make is fully programmable environment.

We don’t teach any of these due to time We don’t teach any of these due to time constraints (and because it’s off topic) but constraints (and because it’s off topic) but new options may be introduced as we go new options may be introduced as we go along. You are welcome to use any option along. You are welcome to use any option you want and do your own web research.you want and do your own web research.

You may also use anything you find in your You may also use anything you find in your homework.homework.

Page 20: Homework There will be 4 homework assignments There will be 4 homework assignments They will each be graded 0-100+ (There will be bonus) They will each

Using IDE under LinuxUsing IDE under Linux

There are plenty of IDE that act as a There are plenty of IDE that act as a wrapper to the above such as (partial list)wrapper to the above such as (partial list) KdevelopKdevelop EclipseEclipse NetbeansNetbeans CodewarriorCodewarrior SlickeditSlickedit

We don’t teach or support them, but you We don’t teach or support them, but you may use them for your homework. may use them for your homework.

Page 21: Homework There will be 4 homework assignments There will be 4 homework assignments They will each be graded 0-100+ (There will be bonus) They will each

Ex. 0Ex. 0

We give you ex. 0 as an optional ex. To iron We give you ex. 0 as an optional ex. To iron out your C skills and code under Linux. out your C skills and code under Linux. Should you submit it, it will be checked. But Should you submit it, it will be checked. But it is not obligatory and will not effect your it is not obligatory and will not effect your grade. (there is also no defense on that grade. (there is also no defense on that one)one)

You should probably google most of your You should probably google most of your problems (there are plenty of good guides) problems (there are plenty of good guides) you can also Email Nezer and Tomer if you you can also Email Nezer and Tomer if you cannot find the answer in google.cannot find the answer in google.

Page 22: Homework There will be 4 homework assignments There will be 4 homework assignments They will each be graded 0-100+ (There will be bonus) They will each

Ex. 0Ex. 0

Create a user shell supporting the following Create a user shell supporting the following commands:commands:

DIR = list filesDIR = list files

CD = change directory (CD .. = usual meaning)CD = change directory (CD .. = usual meaning)

Everything else = try to execute something Everything else = try to execute something with the same file name in the current with the same file name in the current directory using system(3)directory using system(3)

Submit source and makfile.Submit source and makfile.