CMPE 230 Systems Programming, Fall 2012 Homework 1 (due March 20th) Problem 1: Briefly explain in your own words what the following UNIX commands do. 1 4 7 10 13 16 19 22 25 28 31 34 37 40 43 46 49 52 55 58 61 64 67 ls –a ls -l –t cat –A file cat file | more pwd su – ali su ali ssh –X [email protected] locate hello apt-get install httpd nslookup export A=hello source .bashrc ./prog & grep -i "ali" file sort file1 Free kill -9 101 time prog.exe less file adduser ali mail [email protected] ls > file1 2 5 8 11 14 17 20 23 26 29 32 35 38 41 44 47 50 53 56 59 62 65 68 ssh [email protected] ssh –i a.pem [email protected] tar cvf a.tar a tar xvf a.tar gzip a.tar gunzip a.tar.gz ls *.o chown ali file last yum install httpd ping a.boun.edu.tr tail –f file history | tee file bg find –iname “hello” shutdown -h now top whatis ls wget http://a.b.edu du ar qv libmy.a *.o rmdir dir1 ls >> file1 3 6 9 12 15 18 21 24 27 30 33 36 39 42 45 48 51 54 57 60 63 66 69 chmod u+rx file chmod 600 file rm –R * mkdir .h ; mv * ./.h cp –R * ~ali/ ps ax | grep hello mount /dev/cdrom /mnt/cdrom umount /mnt/cdrom finger ali whoami whereis perl script !20 fg diff file1 file2 crontab -u ali -l df rpm -ev httpd passwd Date netstat man –k compile prog.exe < file1 Problem 2: In this project, you will develop two programs, namely, mysort and tests.pl. The program mysort will be implemented in C and will enable you to sort numbers (floats, double, int, long, long long) and measure the time taken by the sorting. It will be invoked as follows: mysort [-b | –q | –i ] [-f | -d | i | -l | -ll ] N Here -b, -q, -i means bubble sort, quicksort and insertion sort respectively. The options –f, –d, –l, -ll are for floats, double, int, long, long long numbers respectively. N is the number of numbers to generate randomly and sort. For example, if you give the following command: >mysort –q –i 0.0001 1000 it will mean that quicksort will be used to sort 1000 integers. The output will be just the time taken to sort the numbers. You should code insertion and bubble sort routines yourself and place them in insert.c and bubble.c files. You should not code quicksort.Quicksort is available in stdlib.h as qsort function. Please do “man qsort” to read the manual page on qsort. The prototypes of insert and bubble functions you write should be the same as that of the qsort function. The defs.h file that contains the prototypes are given below: defs.h file void bsort(void *base, size_t nmemb, size_t size, int(*compar)(const void *, const void *)); void isort(void *base, size_t nmemb, size_t size, int(*compar)(const void *, const void *)); The tests.pl file will be a Perl program that will be run as follows: tests.pl [-f | -d | -i | -l | -ll ] [beg incr times] Here [-f | -d | -i | -l | -ll] means one of float, double, int, long and long long types. [beg inc times] means that all the sorting algorithms will be run for different sizes of the array. These are N=beg,beg+incr, …., beg+times*incr. The project will be located in the PROJ directory. The structure of the PROJ directory and the location of files in this directory are as shown below: PROJ/ BIN/ INCLUDE/ mysort.h LIB/ OBJ/ TESTS/ SRC/ Makefile main.c insertsort.c bubblesort.c tests.pl Implement a Makefile that will carry out the following actions: Command Given Action make all or make The following files will be generated: PROJ/BIN/mysort PROJ/LIB/libmysort.a PROJ/LIB/libmysort.so PROJ/OBJ/main.o PROJ/OBJ/insert.o PROJ/OBJ/bubble.o The following files will be generated: PROJ/LIB/libmysort.a PROJ/LIB/libmysort.so The following files will be deleted: PROJ/BIN/mysort PROJ/LIB/libmysort.a PROJ/LIB/libmysort.so PROJ/OBJ/main.o PROJ/OBJ/insert.o PROJ/OBJ/bubble.o The following test output files will be created: PROJ/TESTS/float-tests-100-100-10 PROJ/TESTS/double-tests-100-100-10 PROJ/TESTS/int-tests-100-100-10 PROJ/TESTS/long-tests-100-100-10 PROJ/TESTS/longlong-tests-100-100-10 The following test output files will be created: PROJ/TESTS/float-tests-10-10-10 PROJ/TESTS/double-tests-10-10-10 PROJ/TESTS/int-tests-10-10-10 PROJ/TESTS/long-tests-10-10-10 PROJ/TESTS/longlong-tests-10-10-10 The following test output file will be created: PROJ/TESTS/float-tests-100-100-10 The following test output file will be created: PROJ/TESTS/double-tests-100-100-10 The following test output file will be created: PROJ/TESTS/int-tests-10-10-10 The following test output file will be created: PROJ/TESTS/long-tests-100-100-10 The following test output file will be created: PROJ/TESTS/longlong-tests-100-100-10 make lib make clean make alltests make alltests BEG=10 INCR=10 TIMES=10 make floattests make doubletests make inttests BEG=10 INCR=10 TIMES=10 make longtests make longlongtests The format of each test result file will be as follows: N qsort time … … … … bubble sort time … … İnsertion sort time … …
© Copyright 2025 ExpyDoc