lectures 1-4

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/67

flashcard set

Earn XP

Description and Tags

Vocabulary flashcards reviewing virtual machine disadvantages, shell commands, and C/C++ usage in system programming.

Last updated 3:51 PM on 10/4/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

68 Terms

1
New cards

VM Disadvantages

Drawbacks of virtual machines including multiplied RAM needs, significant storage usage, and the requirement of custom drivers for best efficiency.

2
New cards

Is

Basic shell command that lists files in current directory.

3
New cards

C/C++ for System Programming

Language choice that provides direct access to memory and hardware, low level memory management, features like pointers and manual memory allocation, wide industry adoption, and low level system calls.

4
New cards

Role of the Operating System

acts as the essential bridge between computer hardware, user applications, and the user

5
New cards

Q: Virtual Machine: Advantages

• efficient use of hardware in data centers

• playground for different systems

• consistent environment across systems

6
New cards

Q: User Program requests?

request system services through system call

7
New cards

Device Drivers

Extract hardware to generic type-specific interface.

8
New cards

Operating System Kernel is in between

Interfaces between user programs and hardware abstraction

9
New cards

What is a system call?

a programmatic way for a user program to request a service from the operating system’s kernel

10
New cards

How does virtual machine simulate the hardware layer?

creates an abstraction layer between physical hardware and the guest operating system

11
New cards

Basic Shell Commands: cd

changes current directory name

12
New cards

Basic Shell Commands: cat “filename” or more “filename”

shows content of file

13
New cards

Memory Hierarchy

Each level acts like a cache for the level below,

Lower is more costly and larger

14
New cards

What are the four tool names

preprocessor (cpp) compiler (cc1) assembly (as) linker (ld)

15
New cards

What is processor memory gap and cache memory?

It is cheaper to make processors go faster than it is to make memory run faster, to deal with this gap system designers include smaller faster storage devices called cache memory to serve as temporary staging area

16
New cards

Compilation Phase IV

Linking, .out .exe

17
New cards

Compilation Phase I

Preprocessing, .c

18
New cards

Compilation Phase II

Compilation, .i

19
New cards

Compilation Phase III

assembly, .o

20
New cards

GUI vs CLI

GUI:

Visual interface, user friendly, limited control

CLI:

Text based, flexible, scripting, efficient

21
New cards

Concurrent Processors and Threads

A process is the operating system’s abstraction for a running

program. Multiple processes can run concurrently on the same

system.

A process can actually consist of multiple execution units, called

threads, each running in the context of the process and sharing the

same code and global data. Multi-threading is also one way to

make programs run faster when multiple processors are available.

22
New cards

Bash Shell

Scripting, command history, most widely used

23
New cards

Z shell

Extended version of bash,

24
New cards

Command Prompt cmd

Basic Shell, comparability, standard

25
New cards

Navigation Command: ls, -l, -lh

Lists content of directory

Lists extended detail content of directory

List extended detail content + file size HUMAN form

26
New cards

Navigation Command: pwd, which

Print current working directory

Shows path

27
New cards

File manipulation: cd

Changes the current directory to the user’s home directory.

28
New cards

Navigation Command: -lt, -lS -a

Lists content sorted by time

Lists content sorted by size

Lists all content and hidden files

29
New cards

rmdir

Remove folder

30
New cards

touch

Create folder with new name

31
New cards

cat

Display contents of filename on terminal

32
New cards

mkdir

create folder

33
New cards

MV

Rename folder

34
New cards

$HOME $USER $PATH

Display path to user home directory

Prints username of user

Display PATH environment variable of user

35
New cards

Compiled Languages (C/C++)

Ready to Run

Often Faster

Source Code is Private


36
New cards

Interpreted Languages (JavaScript)

Cross-platform (interpreter required)

Simpler to test (slower)

Easier to debug (public code)

37
New cards

What are some hybrid languages?

Java and Python

38
New cards

Compiling: gcc

GNU Compiler Collection which

has a host of compilers ready for use. The compiler

infers from the extension that you are trying to

compile a .c file.

39
New cards

Compiling: main.c

This is the main file you want to compile

40
New cards

Compiling: -o

Specify the file output name

41
New cards

Compiling: ./main

Tells your shell to execute the main program

42
New cards

Any nonzero value is ___

True

43
New cards


printf format specifiers: %d %u %f %c %s %x %p



%d or %i int (signed) Prints a signed decimal integer. Both are synonymous for printf.

%u unsigned int Prints an unsigned decimal integer.

%f float, double Prints a floating-point number in decimal notation.

%c char Prints a single character.

%s char[] (string) Prints a string of characters (character array).

%o unsigned int Prints an integer in octal (base 8) format.

%x or %X unsigned int Prints an integer in hexadecimal (base 16) format (lowercase or

uppercase letters).

%p Pointer Prints a memory address, typically in

44
New cards

extern

a special keyword that tells the compiler

that the variable may be defined in another object

file or a library, so the program compiles on

missing variable because the program will

reference a variable in the system or another file.

45
New cards

sizeof


A compile-time operator that returns bytes


46
New cards

struct

keyword that allows you to pair

multiple types together into a new

structure. C-structs are contiguous

regions of memory

47
New cards

typedef

declares an alias for a type. It is like giving a

nickname to a data type.

48
New cards

enum

user-defined data type that consists of a

set of named integer constants. It makes code more

readable and easier to maintain by replacing "magic

numbers" with descriptive names.

49
New cards

Data Type Sizes


char = 1, short = 2, int = 4, long = 8, float = 4, double = 8


50
New cards


Operators: [], ->,., *a, &a, ++, --


subscript

deference

structure

51
New cards

Pointers: &var and *ptr

&var / var (value)

pointerVar (address) / *pointerVar (value)

52
New cards

Pointer Arithmetic

Pointers can be incremented or

decremented to point to the next or

previous memory location.

53
New cards

Strings in C

a one-dimensional array of characters which is

terminated by a null character ‘\0’

C does not store the length of a string

explicitly.

54
New cards

strcpy, strcat, strcmp


copy, concatenate, compare

55
New cards

Common Bug (missing null terminator)

Since our string is not null-terminated,

it may print garbage values or even

crash the program.

56
New cards

Malloc

Allocates a specified number of bytes of memory.

57
New cards

Common Bug: double free

A double-free bug occurs when a program attempts to free a

dynamically allocated memory block that has already been

freed.

58
New cards

Common Bug: Dangling Pointer

Occur when memory is freed but

the pointer is not set to NULL.

● Using a dangling pointer leads to

undefined behavior.

59
New cards

malloc / where does it request memory

Used for memory allocation, allocates a specific number of bytes and returns a pointer, requests memory from the heap (smrk or mmap)

60
New cards

calloc: what and how many functions

Continuous allocation: allocates memory and initialized all bits to zero, similar to Malloc . Typical for arrays and need to be initialized to zero


Takes two arguments, n (number) and sizeof

61
New cards

realloc

Reallocation


Changes the size of an existing block of memory.

● Useful for dynamically growing or shrinking data structures

62
New cards

free

Memory Deallocation


Frees memory previously

allocated by malloc,

calloc, or realloc.

● Prevents memory leaks by

returning memory to the

system.

63
New cards

How does Malloc work internally?

Internally, mallocinteracts with the system’s memory

manager, requesting memory from the heap and

managing metadata to keep track of allocations.

● Allocates a block of memory.

● Returns a pointer to the beginning of the block.

● Must be cast to appropriate pointer type

64
New cards

What are memory leaks?

Occur when allocated memory is

not freed.

● Over time, can exhaust system

memory, leading to crashes.

● Important to always free memory

when it is no longer needed.

65
New cards

Heap Vs. Stack allocation

Quick Comparison

Feature

Stack Allocation

Heap Allocation

Data Size

Small and known at compile-time.

Large or dynamic (size determined at runtime).

Speed

Extremely fast (takes a single CPU instruction).

Slower (requires searching for free memory blocks).

Management

Automatic; freed when the function exits.

Manual (via code) or managed by a Garbage Collector.

Lifetime

Tied strictly to the function's scope.

Can persist as long as the application runs.

Structure

LIFO (Last-In, First-Out) stack frames.

Unordered, fragmented pool of memory.

Primary Risk

Stack Overflow (from deep recursion or huge variables).

Memory Leaks (forgetting to free memory).


66
New cards

in memory leaks, use top to

see increasing memory usage

67
New cards

In memory leaks, use ps to

Inspect memory usage

68
New cards

In memory leaks, use leaks to

Detect memory leak