CSI 3336 Computer Systems Exam 2

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

1/38

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 3:28 AM on 11/5/25
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

39 Terms

1
New cards

How to write c style bash function called foo

foo(){

return 1

}

2
New cards

How to write c bash function called foo

foo(){

echo 1

}

3
New cards

What does shift do in bash?

Shifts the $@ to the left ($2 becomes $1 and so on)

4
New cards

What is the scope of variables in bash?

All variables are totally global unless defined as local than it is local to the scope of function it was created in

5
New cards

In c how do you format printing?

%s : string

%d : decimal

%f : float

%lf : long float

%c : char

%5d : width of 5 right justified

%-5d : width of 5 left justified

%5.2 : width 5, precision of 2

6
New cards

What are the different types of FILE *?

stdin

stdout

stderr

7
New cards

What are the standard file descriptors?

0 : std in

1 : std out

2 : std error

8
New cards

How to open a file with stdio, what happens if it fails

fopen("foo.txt", "r") returns NULL if it does not open and sets errno

9
New cards

What are the flags with opening a file with system call interfaces?

O_RDONLY : read only

O_WRONLY : write only

O_RDWR : read/write

O_APPEND : opens and at EOF

10
New cards

How to open a file with system call interfaces, what happens if it fails

fd = open("foo.txt", O_RONLY)

Returns a file descriptor of -1 if fails.

11
New cards

how to read/write from a file with stdio?

FILE* fp = opens file pointer

char ch;

fscanf(fp, "%c", &ch);

fprintf(fp, &ch);

12
New cards

how to read from a file with system call interfaces?

int fd = opens file descriptor

char ch

read(fd, &ch, 1); => returns size of what was read

write(fd, &ch, 1);

13
New cards

What is the return of c call stat?

0 if success -1 if error

14
New cards

how to create a bit field?

struct foo{

char x : 3;

char y : 5;

}

15
New cards

What is the return of getopt and how can it be used?

char opt;

while ( (opt = getopt(argc, argv, "abcd")) != -1){

switch(opt){

case 'a' : ....

case '?' : => case if option is not found

}

}

16
New cards

what is the return of getopt if the option is not found?

ascii number of '?' i.e. 63

17
New cards

Make a Make file with macros for project with objects main, a, b with a default and cleat target.

CFLAGS = -std=gnu89 -Pedantic -Werror

OBJECTS = main.o a.o b.o

mainTarget: $(OBJECTS)

gcc $(CFLAGS) -o mainTarget $(OBJECTS)

CLEAN:

-rm $(OBJECTS) mainTarget

main.o : main.c a.h b.h

a.o: a.c a.h

b.o: b.c b.h

18
New cards

How to make a flag in getopt have a required argument and how do you access that argument?

"a:" => makes the -a flag required to have argument

To get the arg call the "optarg"

19
New cards

What does c fork() return?

returns the pid, and if it is inside the kid process it will be 0, -1 means it failed to fork

20
New cards

What does wait() do, and how to wait for ALL child processes

Pauses the process and resumes when child terminates. Parent gets the child exit status,

while(wait(NULL) > 0);

21
New cards

unformatted

read and leaves it as it was given

22
New cards

formatted

read and changed into an actual # value

23
New cards

formatted examples

«, », printf()

24
New cards

unformatted examples

get, put, read, write, getline

25
New cards

library calls (stdio)

buffered

26
New cards

system calls

not buffered

27
New cards

what does “clean” do

removes object files. Gets rid of all .o files

28
New cards

write bash function that outputs all subdirectories in current directory

for dirs in $(ls)

do

if [[ -d $dirs]]

then

echo $dirs

fi

done

29
New cards

fragment of code that uses a for loop to display all parameters passed to script

for var in $@

do

echo $var

done

30
New cards

fragment of code that uses a while loop to display all parameters passed to script

while [[$1]]

do

echo $1

shift

done

31
New cards

linux library

.so

32
New cards

env variable allows executable to be executed without user providing absolute path

PATH

33
New cards

regex exp that starts with any number (multiple digits followed by colon)

^[0-9]+:

34
New cards

1 liner to copy a file where path to file is specified in file named dirs to current directory. dirs is in current directory

cp $(cat dirs)./

35
New cards

abandon all changes in vim and quit

:q!

36
New cards

argc

number of arguments

37
New cards

what is a race condition

bug where outcome of a program is determined by which thread or process finishes first

38
New cards

what is blocking

waiting until it receives

39
New cards

what is a zombie

child process in which a parent has not called wait() on. Process cannot end until someone takes its exit status

Explore top notes

note
APHUG Unit 4 Summary
Updated 431d ago
0.0(0)
note
Vocabulary
Updated 1372d ago
0.0(0)
note
Conservation of Mass
Updated 1221d ago
0.0(0)
note
Chapter 12 - The Family
Updated 563d ago
0.0(0)
note
Chapter 9: Transitions
Updated 1022d ago
0.0(0)
note
Fluid Pressure
Updated 1264d ago
0.0(0)
note
APHUG Unit 4 Summary
Updated 431d ago
0.0(0)
note
Vocabulary
Updated 1372d ago
0.0(0)
note
Conservation of Mass
Updated 1221d ago
0.0(0)
note
Chapter 12 - The Family
Updated 563d ago
0.0(0)
note
Chapter 9: Transitions
Updated 1022d ago
0.0(0)
note
Fluid Pressure
Updated 1264d ago
0.0(0)

Explore top flashcards

flashcards
psych exam 5
58
Updated 699d ago
0.0(0)
flashcards
Chemistry Midterm #6
21
Updated 844d ago
0.0(0)
flashcards
HEAL 2600 Midterm **UPDATED**
117
Updated 470d ago
0.0(0)
flashcards
tale of 2 cities vocab 10-13
20
Updated 700d ago
0.0(0)
flashcards
Elements
30
Updated 415d ago
0.0(0)
flashcards
unit 1
62
Updated 1202d ago
0.0(0)
flashcards
psych exam 5
58
Updated 699d ago
0.0(0)
flashcards
Chemistry Midterm #6
21
Updated 844d ago
0.0(0)
flashcards
HEAL 2600 Midterm **UPDATED**
117
Updated 470d ago
0.0(0)
flashcards
tale of 2 cities vocab 10-13
20
Updated 700d ago
0.0(0)
flashcards
Elements
30
Updated 415d ago
0.0(0)
flashcards
unit 1
62
Updated 1202d ago
0.0(0)