Task: High-Level Languages
Enter the labs/lab-02/tasks/high-level-lang/ folder, then enter spport/ Then go through the practice items below.
-
Use
maketo create thehelloexecutable from thehello.gofile (a Go “Hello, World!”-printing program). Useltraceandstraceto compute the number of library calls and system calls. Useperfto measure the running time.Compare the values with those from the “Hello, World!”-printing programs in C and Python.
-
Create a “Hello, World!”-printing program in a programming language of your choice (other than C, Python and Go). Find the values above (library calls, system calls and running time).
-
Create programs in C, Python and Go that compute the N-th Fibonacci number.
Nis passed as a command-line argument. Run the checker (make checkin thehigh-level-lang/solution/tests/folder) to check your results.Use
ltraceandstraceto compute the number of library calls and system calls. Useperfto measure the running time.Compare the values of the three programs.
-
Create programs in C, Python and Go that copy a source file into a destination file. Both files are passed as the two command-line arguments for the program. Run the checker (
make checkin thehigh-level-lang/support/tests/folder) to check your results.Sample run:
student@so:~/.../solution/tests/$ make check make -C ../src make[1]: Entering directory '/media/teo/1TB/Poli/Asistent/SO/operating-systems/labs/lab-02/tasks/high-level-lang/solution/src' go build -ldflags '-linkmode external -extldflags "-dynamic"' hello.go cc -z lazy fibo.c -o fibo go build -o fibo_go -ldflags '-linkmode external -extldflags "-dynamic"' fibo.go cc -z lazy copy.c -o copy go build -o copy_go -ldflags '-linkmode external -extldflags "-dynamic"' copy.go make[1]: Leaving directory '/media/teo/1TB/Poli/Asistent/SO/operating-systems/labs/lab-02/tasks/high-level-lang/solution/src' Fibonacci [C] -- fibo(10) == 55 -- PASSED Fibonacci [C] -- fibo( 5) == 5 -- PASSED Fibonacci [C] -- fibo(20) == 6765 -- PASSED Fibonacci [Python] -- fibo(10) == 55 -- PASSED Fibonacci [Python] -- fibo( 5) == 5 -- PASSED Fibonacci [Python] -- fibo(20) == 6765 -- PASSED Fibonacci [Go] -- fibo(10) == 55 -- PASSED Fibonacci [Go] -- fibo( 5) == 5 -- PASSED Fibonacci [Go] -- fibo(20) == 6765 -- PASSED Copy [C] -- PASSED Copy [Python] -- PASSED Copy [Go] -- PASSEDUse
ltraceandstraceto compute the number of library calls and system calls. Useperfto measure the running time. Use source files of different sizes. Compare the outputs of these commands on the three programs.
If you’re having difficulties solving this exercise, go through this reading material.