Homework remaining after classes
Homework tasks should be stored/copied in corresponded directories, named after class topic. All binaries should work on the sugon server.
See >>> link to classes pages.
>>>
>>>
Make sure you can connect to sugon server over ssh
>>>
Connect to server from home!
If using windows, you may need SSH. It's better to install Git for windows and run linux-like console from "Git bash" menu
Compile an ru any program on server
>>>
>>>
(can be done in class if time allows)
Write a program that utilizes memory sparsely, so it's footprint 100% misses 2-way associative MARS cache simulator, but (almost) fits into 4-way associative cache with 16 lines (blocks) of cache
Make it available at sugon server in the subdirectory asm:
1 localhost$ ssh sugon -p 2131 2 ... 3 [your_login@sugon ~]$ mkdir src 4 [your_login@sugon ~]$ ls -a src 5 . .. 6 [your_login@sugon ~]$ exit 7 ... 8 localhost$ scp -P 2131 progCache.asm your_login@sugon:src/ 9 progCache.asm 100% 285 26.7KB/s 00:00 10 localhost$ ssh sugon -p 2131 11 ... 12 [your_login@sugon ~]$ mkdir src 13 [your_login@sugon ~]$ ls -a src 14 . .. progCache.asm 15
>>>
If you have non-MIPS environment, try these programs there
>>>
- write a program that detects maximum possible size of malloc-ed memory
read man malloc to learn how malloc() reports a failure
spoiler:
do not forget to free()
>>>
- Finish all tasks
Place the solution to the sugon server under the name fpointer.c. E. g. like this:
$ scp -P -P 2131 yourprog.c your_login@sugon:fpointer.c
(note the address of sugon)
>>>
Pick up your favorite debugger and learn how to use it
>>>
- Copy both programs (fprintf and fwrite versions) to sugon server
>>>
All three programs must reside in 10_fileio subdirectory of your home directory on sugon server. Use scp if you've done the task outside the server.
>>>
- Finish all tasks
Improve argredir.c to check error status of all operations performed and print an error message when en error is occurred
See RETURN VALUE (or alike) section of each function manpage
use perror
Write a new program pip2redir.c that resembles piperedir, but forks both child processes (as seen at lecture), waits for both to end and prints both commands exit status
Note wait() returns after either of children is stopped, you need to check if ECHILD is returned to indicate there is no more living child
>>>
- Finish all 4 tasks
>>>
Write a function countbytes(FILE *fp, int a, int b) that receives opened binary FILE *fp as the first argument and a pair of '0…255' integers a and b as the second and the third arguments. The function counts how many bytes a<=byte<=b are in the input file.
In second file write main() that parses three agruments (input file name and two integers), opens the file, calls countbytes(), closes the file and outputs countbytes() return value.
Create a Makefile for:
building countbytes program
- building 3 test input files
zeroes with 1000 zeroes
words with 1000 bytes from the start of /usr/share/dict/words file (or another english words long file)
random with 1000 random bytes
- running 5 tests against these files:
- searching 0 0 in zeros (program should print 1000)
- searching 10 100 in zeros (program should print 0)
searching 65 120 in words (program should print something)
- searching 200 220 in words (program should print 0)
searching 10 100 in random (program should print something)
clearing all the mess (all generates, including *.o, test files and prorram itself)
>>>
Finish all tasks
>>>
Finish all tasks
>>>
Modify last program to:
Exit after getting signalQ three times
- Check every syscall return values on error state
>>>
- Finish all tasks
>>>
Test tasks : TODO