CS2850 Operating Systems Flashcards
What is Valgrind?
Valgrind is a debugging tool that acts like a virtual machine.
It intercepts all the memory accesses of your program and ensures you aren’t doing anything obviously wrong.
Much like Java will throw an “Index out of bounds” exception if you try to go outside of an array, Valgrind will report when your program is accessing garbage values in memory or leaking memory.
Because Valgrind only monitors a single run of your program it cannot guarantee that your code is perfect, but it will catch a lot of errors.
What is gcc?
GCC isa free and open source compiler collection for C, C++, and other languages, written for the GNU operating system.
What is clang?
What is a macro in C?
A macro is a fragment of code that is given a name. You can define a macro in C using the #define pre-processor directive.
What does #include <stdio.h>
do in C?
It looks for the stdio.h
file and effectively copy-pastes it in the place of this#include
statements. This file contains so-called function prototypes of functions such asprintf()
,scanf()
, … so that compiler knows what are their parameters and return values.
What is struct
in C?
Structures in C (struct
) are equivalent to classes in other languages.
Note, with structures, members are public by default.
What is a segfault error?
A segfault
error occurs when a program tries to access memory that it doesn’t own.
What does the -g2
flag do when compiling a file?
The -g2 flag tells the compiler to add extra information to the executable (such as line numbers.)
One reason this is useful is that it allows debugging tools can relate memory addresses to line numbers.
What is a leaked memory
error?
What is an Invalid Memory Read
error?
What is Cygwin?
Cygwin is a project that provides a large collection of GNU and Open Source tools and a DLL that emulate Linux functionality on Windows . It is a Linux-like environment for Windows that allows you to run Linux commands and programs on your Windows system . You can install, use, and update Cygwin packages, verify the signature of setup-x86_64.exe, and choose the minimal base packages or the full Cygwin distribution .
Source: Conversation with Bing, 12/12/2023
(1) Cygwin. https://cygwin.com/.
(2) Cygwin - Wikipedia. https://en.wikipedia.org/wiki/Cygwin.
(3) Cygwin Installation. https://cygwin.com/install.html.
Give examples of features that C does not include
C does not include:
- operators acting on
composite objects
such as a string of characters, an array, or lists - dynamical memory allocation facility
- READ or WRITE statements
- built-in file access methods
What is ANSI C?
ANSI C is a standard version of C:
- a set of rules have been fixed for C-programs to be machine-independent and compatible
- the same C code can work on computers with different operating systems
- what changes is how .c files are run i.e. the corresponding executable (binary) program
- the binary file obtained from a .c source file, is produced by a system-dependent compiler
What is an array and what problem does malloc() solve?
An array is a collection of a fixed number of values. Once the size of an array is declared, you cannot change it.
Sometimes the size of the array you declared may be insufficient. To solve this issue, you can allocate memory manually during run-time. This is known as dynamic memory allocation in C programming.
To allocate memory dynamically, library functions are malloc()
, calloc()
, realloc()
, and free()
.
These functions are defined in the <stdlib.h> header file.</stdlib.h>