systems final

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

1/23

encourage image

There's no tags or description

Looks like no tags are added yet.

24 Terms

1
New cards

common gcc commands


  • gcc <source code>: compiles and links an executable

  • gcc <source file> -o <output file> OR gcc -o <source file> <output file>: compiles and links an executable using given name

  • gcc -c <source file>: compiles into an object file

  • gcc <object file(s)> -o <output file>: link 1 or more object files into an exectuable


2
New cards

process

  • OS abstraction representing a running program and its execution state

  • OS creates processes


3
New cards

OS process details

  • process control block

  • process ID

  • parent process ID

  • process group, session IDs

  • owner and group user accounts

  • address space: code, data for variables, heap objects, etc

  • flags

  • process state


4
New cards

process states

  • Running: being/scheduled to be executed by CPU

  • Sleeping: waiting for event to happen before execution (i.e. user input, timer, etc); it’s in wait queue

  • Uninterruptible sleep: similar to sleep

  • T (stopped): not in queue; has to be told to continue

  • Zombie: dead but still taking space


5
New cards

int and char types

  • int

  • short and long int

  • unsigned int

  • unsigned short and unsigned long int

  • char

  • unsigned char

  • short int > char

  • long int > short int

  • compiler automatically truncates if expression has a bigger size than allowed


6
New cards

floating point math

always done with doubles

7
New cards

bitwise operators

  • a « b: shifts bits of [a] left by [b] places ( = a * 2b)

  • a » b: shifts bits of [a] right by [b] places ( = a/2b)


8
New cards

objects

  • contiguous segment of memory that has some sort of identity

  • to use, know the location in memory and type of data it holds


9
New cards

pointer

  • holds location/address of a type

  • type of pointer = type of object

  • ex) &x //gets the pointer/address to x

    • x = 5 //changes value in x


10
New cards

arrays

  • linear contiguous sequence of elements of the same type

  • to use, know where it is (tracked by a pointer) and size of elements

  • compiler automatically creates/destroys storage for array variables


11
New cards

strcpy (variable, value)

copies value into variable

  • variable has to be big enough to hold enough value


12
New cards

structs

  • used to collect a fixed amount of data of different types

  • when you have the struct value, use “struct.variable”

  • when you have a pointer to a struct, use “struct→variable”

  • sizeof(struct) = multiple of largest alignment, including any padding needed


13
New cards

typedef <type expression> <new name>

sets nickname

ex) typedef struct list_node list_t //new name = list_t

14
New cards

enumuerated types

  • set of named int constants

  • ex) enum direction {north, east, south, west} //each is assigned a number starting from 0


15
New cards

union

  • stores different types

  • sizeof(union) = largest alignment

  • use dot operator to call variables


16
New cards

dynamic allocation

ability to create new objects at run time

17
New cards

void *malloc (size_t length)

returns pointer to requested block size

18
New cards

void *calloc (size_t count, size_t size)

allocates count *size chars and intitializes all to 0

19
New cards

void realloc (void ptr, size_t length)

changes size of ptr to length

20
New cards

rounding down to multiple of 8

n & ~7

  • sets the last 3 bits to 0


21
New cards

rounding up to a multiple of 8

(n+7) & ~7

  • makes sure 1-8 = 9-16 = 16, etc


22
New cards

preprocessor

  • runs before compilation

  • functions

    • macro replacement

    • conditional compilation: decide what version of code to use

      • avoids problems

        caused by including a header file multiple times

  • automatically converts number-like macro values to

    integers and supports some limited arithmetic and comparison operators


23
New cards

header components

  • type definitions

  • function prototypes

  • global varaible declaration

  • macros


24
New cards

process termination

  • returning from main: 0 = success

  • call exit(): closes open files, releases memory pages, etc

  • atexit (void