CS 240

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

1/310

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 1:29 AM on 3/29/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

311 Terms

1
New cards

UNIX

Family of OS that derive from AT&T Unix

  • Includes Linux and its distributions

2
New cards

Unix philosophy

  • OS should have simple tools

  • Each tool has a limited, well-defined function

  • Relationships between programs are stronger than the programs themselves

3
New cards

Main features of UNIX

  • Plain text for storing data

  • Hierarchical file system

  • IPC

  • Smaller, more numerous programs

  • Portability

4
New cards

Kernel (UNIX)

Source code of OS

  • conf: configuration

  • dev: device drivers

  • sys: system kernel

  • h: header files

5
New cards

Components of UNIX systems

  • Kernel

  • Development environment (only on older machines)

  • Commands

  • Documentation

6
New cards

Commands (UNIX)

  • sh: shell (command-line)

  • System and user utilities

  • Document formatting

  • Graphics

  • Communications

7
New cards

Environment variables

Variables added to the command line

8
New cards
$TERM=vt100

Sets terminal to lowest common denominator

  • Corrects an incorrectly set terminal

9
New cards
$PS1

Sets the default command for each prompt

10
New cards
$PS2

Sets the default command on execution error

11
New cards

DISPLAY (Environment Variable)

Default display identifier for X11 programs

12
New cards

HOME (Environment Variable)

Home directory

13
New cards

IFS (Environment Variable)

Returns the internal field separator used for word splitting

14
New cards

LANG (Environment Variable)

Sets the system language

15
New cards

LD_LIBRARY_PATH (Environment Variable)

List of directories used to build a process image

16
New cards

PATH (Environment Variable)

Search path for commands

17
New cards

PWD (Environment Variable)

Current working directory

18
New cards

RANDOM (Environment Variable)

Returns random integer between 0 and 32,767

19
New cards

SHLVL (Environment Variable)

Counts the number of bash instances

20
New cards

TERM (Environment Variable)

Display type

21
New cards

TZ (Environment Variable)

Time zone

22
New cards

UID (Environment Variable)

User ID

23
New cards

C preprocessor

Text file processor used to parse code

24
New cards

Preprocessor directives

Commands in code starting with a #

25
New cards

Including contents of files (C preprocessor)

  • Newer versions allow #embed for binary resource inclusion

#include <file>
#embed <file>

26
New cards

Conditional compilation (C preprocessor)

#if <condition>
#else
#elif <condition>
#endif <condition>
#ifdef <var>
#ifndef <var>

27
New cards

Macro string replacement (C preprocessor)

#define <object/function> <value>

28
New cards

Variadic macro (C preprocessor)

Macro with variable arguments

29
New cards

Macro expansion

Replaces macro tokens with replacement text

  • Strings and comments are ignored

30
New cards

Undefined macro (C preprocessor)

#undef <value>

31
New cards

Line number (C preprocessor)

__LINE__

32
New cards

File name (C preprocessor)

__FILE__

33
New cards

Defined operator (C preprocessor)

defined(<macro>)
defined <macro>

34
New cards

Token stringification (C preprocessor)

# -> str(s)

35
New cards

Token concatenation (C preprocessor)

##

36
New cards

Abort (C preprocessor)

#error

37
New cards

Warning (C preprocessor)

#warning

38
New cards

Chains headers of the same name (C preprocessor)

#include_next

39
New cards

C compilation process

  • Source File

  • Preprocessor

  • Compiler

  • Assembler

  • Linker

40
New cards

Preprocessing

  • Removes comments

  • Expands macros and files

  • Processes conditional compilation

41
New cards

Compiling

C code → Assembly code

42
New cards

Assembling

Assembly code → machine code

43
New cards

Linking

Function calls are linked with their definitions in machine code

44
New cards

Static Linking

All code is copied into one executable file

45
New cards

Dynamic Linking

Only names of shared libraries are added, which are referred to upon execution

46
New cards

Macro

Symbolic variable containing a value, expression, or code

  • Created with #define

  • Substituted during compilation

47
New cards

Convention for macro names

All uppercase with underscores

48
New cards

Types of macros

  • Object-like

  • Chain

  • Multi-line

  • Function-like

49
New cards

Object-like macro

Contains a value or expression

50
New cards

Chain macro

Macro value is dependent on another macro

51
New cards

Multi-line macro

Span multiple lines for readability

52
New cards

Function-like macro

Takes parameters and invoke commands

53
New cards

Pointer

A variable that stores the memory address of another variable

54
New cards

Pointer declaration syntax

<type> *<var_name>

55
New cards
&<var_name>

Returns the memory address (pointer) of a variable

56
New cards

Dereferencing a variable

*<var_name>

57
New cards

Pointer size

  • 32-bit system: 4 bytes

  • 64-bit system: 8 bytes

  • Independent of the pointer type

58
New cards

sizeof()

Returns the number of bytes of a variable or type

59
New cards

Null pointer

Pointer variable that doesn’t point to a memory address

60
New cards

Void pointer

Pointer variable that has no data type

61
New cards

Wild pointer

Pointers that have not been initialized

  • Extremely dangerous

  • Can cause crashes, data aborts, or even data corruption

62
New cards

Dangling pointer

Pointers that were freed

  • Extremely dangerous

  • Can cause crashes, data aborts, or even data corruption

63
New cards

Function pointer

  • Pointer that stores the address of a function

    • Allows for functions to be passed as arguments

    • Dynamic invocation

    • Callback functions

64
New cards

Multi-level pointer

Pointer that points to another pointer

65
New cards

Stack memory

Location of local variables

66
New cards

Advantages of pointers

  • Dynamic memory allocation

  • Efficient data collection navigation

  • Easy access to memory

  • Can create complicated data structures

  • Better performance with less code

67
New cards

Disadvantages of pointers

  • Easy to corrupt memory

  • Difficult to understand

  • Vulnerable to memory leaks

  • Accessing pointers takes longer

  • Segmentation faults can occur

68
New cards

Dynamic memory allocation

Memory can be allocated, resized, and freed during runtime

  • Memory is manually controlled

  • Memory is stored in a heap rather than a stack

69
New cards

malloc(<bytes>)

Allocates <bytes> contiguous bytes of memory on the heap at runtime

  • Returns a pointer to the memory

  • Memory is uninitialized

  • Always check return value

70
New cards

calloc(<bytes>, <var_size>)

Allocates <bytes> * <var_size> contiguous bytes of memory on the heap at runtime

  • Memory is initialized to 0, or NULL if it fails

71
New cards

free(<pointer>)

Releases memory to the OS

  • Avoids memory leaks

  • Set the pointer back to NULL

72
New cards

realloc(<pointer>, <bytes>)

Resizes previously allocated memory block

  • If it fails, memory is not freed automatically

  • Use NULL handling

73
New cards

Issues with dynamic memory allocation

  • Memory leaks

  • Dangling pointers

  • Fragmentation (inefficient use of heap memory)

  • Allocation failures (crashes)

74
New cards

struct <name> {} <var> = {};

Creates a blueprint for data collection

  • No functions allowed

  • Each member has its own memory

  • Dot operator for property access

  • Definition is optional

  • Allowed in arrays

75
New cards

Union

Members share the same memory

  • Only one value may be used at a time

76
New cards

Union declaration

union <union_name> {}

77
New cards

Union invocation

union <union_name> {}

78
New cards

Danger with manipulating union values

Only the last assigned member holds a valid value

79
New cards

Size of a union

The size of its largest member

80
New cards
typedef <existing_type> <new_type>;

Allows for user-defined datatypes through aliases

  • Turns a variable definition into a type declaration

81
New cards

Bitfield

Members that have a fixed size

82
New cards

Bitfield declaration (struct)

<data_type> <member_name> : <width>;

  • Member is limited to the number of bytes in <width>

  • Only ints may be used

  • signed/unsigned must be defined explicitly

83
New cards

Uses for bitfields

  • Saving storage space

  • Transmitting data

  • Encryption

84
New cards

Downsides of bitfields

  • Can lead to overflow or underflow if values exceed bit allocation

  • Cannot be put into an array

85
New cards

UNIX file abstraction

  • A file is a sequence of bytes

  • Everything is a file

86
New cards

Danger with printing variables

Variables must be printed through format specifiers

87
New cards

int size

2 or 4 bytes

88
New cards

float size

4 bytes

89
New cards

double size

8 bytes

90
New cards

char size

1 byte

91
New cards

double format specifier

%lf

92
New cards

Unsigned integer format specifier

%zu

93
New cards

Extended keywords

Controls the memory size of a variable

94
New cards

short (extended keyword)

Narrows value to 2 bytes

95
New cards

unsigned (extended keyword)

Removes negative values but doubles the range

  • 2 or 4 bytes (depending on system)

96
New cards

long (extended keyword)

Widens int to 4 or 8 bytes

  • Depends on system

97
New cards

long long (extended keyword)

Forces int to 8 bytes

98
New cards

long double (extended keyword)

Offers more precision than double

99
New cards

short int format specifier

%hd

100
New cards

unsigned int format specifier

%u

Explore top notes

note
AP Gov: Chapter 1 Vocab
Updated 1299d ago
0.0(0)
note
Unit 7: Evolution (Biology)
Updated 710d ago
0.0(0)
note
Mitosis
Updated 751d ago
0.0(0)
note
diplomacy
Updated 1251d ago
0.0(0)
note
Le Chatelier's Principle
Updated 1158d ago
0.0(0)
note
AP Gov: Chapter 1 Vocab
Updated 1299d ago
0.0(0)
note
Unit 7: Evolution (Biology)
Updated 710d ago
0.0(0)
note
Mitosis
Updated 751d ago
0.0(0)
note
diplomacy
Updated 1251d ago
0.0(0)
note
Le Chatelier's Principle
Updated 1158d ago
0.0(0)

Explore top flashcards

flashcards
Kite Runners Vocab
35
Updated 68d ago
0.0(0)
flashcards
Midterm
238
Updated 389d ago
0.0(0)
flashcards
Describing People SPN2 PreAP
91
Updated 221d ago
0.0(0)
flashcards
Cellular Respiration Review
22
Updated 1215d ago
0.0(0)
flashcards
apush 3.1-3.4
52
Updated 578d ago
0.0(0)
flashcards
Chapter 9 Med Term
25
Updated 1217d ago
0.0(0)
flashcards
Posterior Muscles
47
Updated 1244d ago
0.0(0)
flashcards
SALUD Y BIENESTAR vocabulario
33
Updated 913d ago
0.0(0)
flashcards
Kite Runners Vocab
35
Updated 68d ago
0.0(0)
flashcards
Midterm
238
Updated 389d ago
0.0(0)
flashcards
Describing People SPN2 PreAP
91
Updated 221d ago
0.0(0)
flashcards
Cellular Respiration Review
22
Updated 1215d ago
0.0(0)
flashcards
apush 3.1-3.4
52
Updated 578d ago
0.0(0)
flashcards
Chapter 9 Med Term
25
Updated 1217d ago
0.0(0)
flashcards
Posterior Muscles
47
Updated 1244d ago
0.0(0)
flashcards
SALUD Y BIENESTAR vocabulario
33
Updated 913d ago
0.0(0)