CSIT 231 Spring Final Exam Study Guide Filled Lecture 11 - Lecture 21

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/103

flashcard set

Earn XP

Description and Tags

Flashcards for the lectures spanning lecture 11 and lecture 21

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

104 Terms

1
New cards

What are pointers to functions often used to implement?

Polymorphism

2
New cards

What will the compiler mistake the pointer name for if it is not encapsulated in parentheses?

Function prototype

3
New cards

What is a struct?

A user defined data type that is used to group items of different types into a single type

4
New cards

What are the items inside a struct known as?

Members

5
New cards

How are values in structs stored in memory?

Stored contiguously in memory

6
New cards

We can directly access members of a structure using what operator?

The period

7
New cards

When accessing members of a structure using pointers, what operator must we use?

The arrow operator

8
New cards

Why is it more efficient to pass a pointer to a function vs the entire structure?

Only the memory address is passed, not a copy of the entire struct

9
New cards

Is explicit memory allocation faster than implicit memory allocation?

Yes, explicit memory allocation is faster

10
New cards

Do explicit memory allocations use more or less memory compared to implicit memory allocation?

Explicit memory allocation uses less memory

11
New cards

Enums are a special user defined data type that are used to represent what?

A group of global constants

12
New cards

Why might it be better to use an Enum instead of using #define?

Enum allows us to group related values together which follow bounds checking and scope rules. #define does not group values together, it just creates a macro for a global static variable

13
New cards

What issues may arise from #define?

define does not have type checking and do not obey scope rules

14
New cards

What is the default value assigned to each member of the enum?

The default value will start at 0

15
New cards

Following the default value, what value is assigned to each subsequent enum value?

Each subsequent value will be assigned a value 1 greater than the last

16
New cards

If there is an enum with the first value set to 20, what is the subsequent value?

21

17
New cards

What is a union?

A user defined data type consisting of a sequence of members whose storage overlaps

18
New cards

When we define a union we can store a variety of data types, but where/how is everything stored in memory?

All members share the same memory space

19
New cards

Based on memory spacing of unions, how many members can hold a value at one time?

The value of at most one member at a time can be stored in a union

20
New cards

How do you determine the size of the union?

The size of the union is based on the size of its largest member

21
New cards

Why are unions useful (benefits of a union)?

Unions can save space by sharing memory for different types of data

22
New cards

What operator do we use to access members of a union?

The period ( . ) operator

23
New cards

What is BASH?

The Bourne Again Shell (bash) is a command interpreter and a high-level programming language

24
New cards

When using the shell as a programming language, it processes commands where?

Commands stored in files called shell scripts

25
New cards

What is the special sequence of characters needed on the first line when scripting?

! Is known as the shebang or hashbang

26
New cards

Why is shebang needed?

It helps tell the operating system which shell should execute the file

27
New cards

Ways you can cause the shell to alter where standard input of a command comes from and where standard output goes to is known as what?

Redirection

28
New cards

What symbol represents standard output redirection?

or 1>

29
New cards

What symbol represents standard input redirection?

< or 0<

30
New cards

What symbol represents standard error redirection?

2>

31
New cards

What symbol represents append output redirection?

>

32
New cards

What does redirecting with a > do?

Instructs the shell to redirect the output of a command to the specified file instead of to the screen

33
New cards

What does redirecting with a < do?

Instructs the shell to redirect input of a command from a file

34
New cards

What does redirecting with a >> do?

Causes the shell to add new information to the end of a file, leaving existing information intact

35
New cards

What does redirecting with a 2> do?

Redirects output to standard error

36
New cards

What is a file descriptor?

Is the place a program sends its output to and gets its input from

37
New cards

What is /etc/passwd?

Is a list of users recognized by the system

38
New cards

What is /etc/shadow used for?

Where actual passwords are stored

39
New cards

What are the first four fields of a /etc/passwd entry represent?

Login name, Placeholder for the password, User ID, Group ID

40
New cards

List the first step in adding a node to the front of a doubly linked list

Create a new node using malloc

41
New cards

List the first step in adding a node to the tail of a doubly linked list

We create a new node using malloc

42
New cards

What do header files include?

Includes C declarations and macro definitions to be shared across multiple files

43
New cards

The C preprocessing directive #include is a request to the compiler to do what?

To load the contents of a specific header file, so that they can be used in the program

44
New cards

What is double inclusion?

Including the same header file twice across multiple files

45
New cards

What is the solution for double inclusion?

Header guards

46
New cards

When using header guards the preprocess will check what?

Whether the header guards unique name has been previously defined in the translation unit

47
New cards

What is linking?

Is the process of collecting and combining various pieces of code and data into a single file that can be copied into memory and executed

48
New cards

What are the three benefits of linking multiple files together versus creating one large source file?

Modularity, easier to maintain smaller more manageable modules than one big one, code can be reused

49
New cards

What is symbol resolution?

Is to associate each symbol reference with exactly one symbol definition

50
New cards

What is a symbol?

Global variables and functions

51
New cards

What is the symbol table?

Is an array of structs

52
New cards

What does each symbol entry include?

Includes name, size, and location of the symbol

53
New cards

What is relocation?

Compilers and assemblers generate code and data sections that start at address 0, The linker relocates these sections by associating a memory location with each symbol definition, Then modifying all of the references to those symbols so that they point to this memory location

54
New cards

What are the three different types of object files?

Relocatable object file (.o), Executable object file (a.out), Shared object file (.so)

55
New cards

What are global, external, and local symbols?

Global, symbols defined by module m that can be referenced by other modules, External, global symbols that are referenced by module m but defined by some other module, Local, symbols that are defined and referenced exclusively by module m

56
New cards

What are the three rules when dealing with duplicate symbols?

Rule 1: Multiple strong symbols are not allowed, Rule 2: Given a strong symbol and multiple weak symbols, choose the strong symbol, Rule 3: If there are multiple weak symbols, pick an arbitrary one

57
New cards

Why is it bad to put all standard C functions into a single relocatable object module?

It is a huge waste of space as every executable file in the system would have a copy of these functions even if they are not using them, Changing any of the functions would require recompilation of the entire source code

58
New cards

Static libraries are stored on disk in a format known as what?

Archive (.a)

59
New cards

What are the disadvantages of static libraries?

Duplication in the stored executables (every function needs libc), Duplication in the running executables, Minor bug fixes of system libraries require each application to explicitly relink

60
New cards

What modern solution is available that is made of object files that contain code and data that are loaded and linked into an application dynamically, at either load-time or run-time?

Shared libraries (DLL’s) or Shared object (.so) files

61
New cards

What is dynamic linking?

An object module that, at either runtime or load time, can be loaded at an arbitrary memory address and linked with a program in memory

62
New cards

What is the simplest form of control flow?

Is a “smooth” sequence where instructions are adjacent in memory

63
New cards

Abrupt changes in control on the system are referred to as what?

Exceptional Control Flow (ECF)

64
New cards

The process of transferring control to the OS kernel in response to some events is called what?

Exception

65
New cards

What is a process?

Is an instance of a program in execution

66
New cards

What does preempted mean?

Temporarily suspended

67
New cards

A logical flow whose execution overlaps in time with another flow is called what?

A concurrent flow, the two flows are said to run concurrently

68
New cards

What is the first process in the system?

Init or systemd

69
New cards

What is the ID assigned assigned to every process by the kernel called?

Process ID

70
New cards

Which process states means the process is waiting for an event or resources?

Sleeping/Waiting

71
New cards

Which process state means the process is trying to exit?

Zombie

72
New cards

Which process state means the process is suspended (not allowed to execute)

Stopped

73
New cards

What is the process table?

The process table contains all information about each process

74
New cards

What is a process control block?

Each process table entry contains enough information to restart (put in running state) a process that is waiting or in a ready state

75
New cards

What is a context switch?

Control flow passes from one process to another

76
New cards

What is a thread?

Is a path of execution

77
New cards

What advantages are gained when using multithreading?

Fast thread creation, fast context switch, fast communication across threads

78
New cards

What are the advantages of multiprocessing?

Reduced execution time, parallel execution, process isolation

79
New cards

What does fork do?

Returns 0 to the child process, child’s PID to parent process

80
New cards

What is a race condition?

Threads can access shared data and try to change it at the same time

81
New cards

What is a mutex lock?

A mutex lock, otherwise known as mutual exclusion, is an operation used to prevent simultaneous possession of shared resources

82
New cards

What is the critical section?

Is a portion of code only one thread should execute at a time

83
New cards

What is a semaphore?

Is a global variable with a nonnegative integer value that can only be manipulated by two functions

84
New cards

What are the two functions used to lock and unlock a semaphore?

semwait() and semsignal()

85
New cards

What is the main objective of multiprogramming?

To have some process running at all times, maximizing CPU utilization

86
New cards

What is the responsibility of the CPU scheduler?

When the CPU becomes idle, the CPU scheduler selects a process from the processes in memory that are ready to execute and allocates the CPU to that process

87
New cards

What's a preemptive scheme?

The OS can interrupt a running process and switch to another process before the current one finishes

88
New cards

What is a signal?

Is a small message that notifies a process that an event of some type has occurred in the system

89
New cards

For what two reasons can a signal be sent?

The kernel detected a system event (like divide by zero), A process has invoked the kill function that requires the kernel to send a signal to the process

90
New cards

When a process receives a signal, what three actions can it take?

Ignore, Terminate, Catch

91
New cards

What is a pending signal?

A signal has been sent but not yet received

92
New cards

What are blocked signals?

A process can selectively block the receipt of certain signals, Blocked signals can be delivered but the pending signal will not be received until the process unblocks the signal

93
New cards

Each signal type has a predefined default action, what are the four actions?

The process terminates, The process terminates and dumps the core, The process stops (suspends) until restarted by a SIGCONT signal, The process ignores the signal

94
New cards

A transaction between a client and a server consists of four steps, what are they?

The client initiates a request to the server, The server receives the request, understands what it is asking for, then processes the request, The server then sends a response to the client, and waits for a new request, The client receives the response and processes it

95
New cards

A network is a hierarchical system organized by geographical proximity, what are the three proximities?

SAN (System area network), LAN (Local area network), WAN (Wide area network)

96
New cards

How are IP addresses stored in memory for a network?

IP addresses are stored in network byte order, Otherwise known as big-endian byte order

97
New cards

What is a socket?

An endpoint of a connection

98
New cards

What is a socket pair?

A socket address is (IP_Address:Port), Connection socket pair is (Client socket address, server socket address)

99
New cards

What is an ephemeral port?

Assigned automatically by client kernel when client makes a connection request

100
New cards

What is a well-known port?

Associated with some service provided by a server (e.g., port 80 is associated with Web servers)