Lecture 7 Flashcards

Structure

1
Q

What is the primary purpose of arrays in programming?

A

Arrays allow the combination of multiple elements of the same type under one logical entity

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How do structures differ from arrays in programming?

A

Structures allow you to combine elements of different types under one logical entity

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the purpose of defining a new type called struct student?

A

It creates a new data type that allows you to group multiple related variables (members) of potentially different types under one logical entity.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Does defining struct student allocate memory for an instance?

A

No, defining a struct does not declare a new instance or allocate any memory; it only defines the type.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Where in a program should the definition of a struct type be placed?

A

The definition of a struct should be placed at the top of the program, outside any functions, and is almost always in header files.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How do you create an instance of the struct student type?

A

You can create an instance by declaring it as struct student s; or struct student s1, s2;.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How do you access individual members of a struct variable?

A

You access members using the dot operator, e.g., s.number, s.grade, etc

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the role of the dot operator in relation to structures?

A

The dot operator (.) is used to access individual members of a previously declared structure variable.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What does defining a structure do in C?

A

Defining a structure tells the compiler about the new type but does not allocate any storage for it.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is the purpose of declaring a variable of a particular structure type?

A

Declaring a variable specifies the type and gives an identifier (name) to that variable, which allows storage allocation.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is the primary distinction between defining a structure and declaring a variable of that structure type?

A

Defining a structure introduces the type to the compiler, while declaring a variable allocates memory and associates it with a name.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

A binary digit is called?

A

a “bit”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is the significance of the index of each byte in memory?

A

The index of each byte is known as its address, which uniquely identifies that byte in memory.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is Binary?

A

a number system comprised of 2 digits; 0 and 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How can you conceptualize the memory of a computer system?

A

The memory of a computer system can be thought of as an array of bytes connected to the processor.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How does the processor access memory locations?

A

The processor can access any memory location by using the corresponding addresses.

15
Q

What do we call a human-readable notation

A

assembly language

16
Q

a program that translates a symbolic version of instructions into the binary version

A

Assembler

17
Q

the processor has a “counter” that keeps track of the
address holding the current instruction being executed

A

program counter (or PC)

17
Q

Machine (and assembly) language is made up of?

A

instructions

18
Q

the idea that instructions and data of many types can be stored in memory as numbers, leading to the stored program
computer

A

Stored-program concept

19
Q

text segment

A

instructions reside
here

20
Q

Initialized data segment

A

holds literals and constants in code

21
Q

A data structure allows only
two operations: “push” and “pop”

A

stack

22
Q

uninitialized data segment

A

contains static and global
variables

23
Q

which data structure has space for automatically-allocated variables

A

stack

24
Q

which data structure has space for dynamic memory allocation

A

heap

25
Q

To request memory from heap

A

malloc()

26
Q

to return the memory to heap

A

free()

27
Q

Program translation, assembly, linking,
and loading

A

When a C program is compiled and run: 1) The compiler translates high-level code to assembly. 2) An assembler converts assembly to machine code, creating object files. 3) The linker combines object files and libraries into an executable. 4) The loader loads the executable into memory and starts execution, potentially linking at runtime.

C->A->O->LI->E->L

28
Q

What is a process in the context of an operating system?

A

A process is a container for a single executable and represents an instance of a running program.

29
Q

What does the operating system do regarding multiple processes?

A

The operating system provides a method for switching between processes and selecting the next process to run, known as scheduling.

30
Q

What does switching between processes involve?

A

Switching between processes involves saving and restoring the program counter and many other processor status elements.

30
Q

How many threads can a process have?

A

A process can have one or many threads.

30
Q

What is a thread

A

a path of execution

31
Q

multiprocessor architectures operate using

A

shared memory

31
Q

multiprocessor architectures

A

Modern computer systems often have more than one processor