Lecture 7 Flashcards
Structure
What is the primary purpose of arrays in programming?
Arrays allow the combination of multiple elements of the same type under one logical entity
How do structures differ from arrays in programming?
Structures allow you to combine elements of different types under one logical entity
What is the purpose of defining a new type called struct student?
It creates a new data type that allows you to group multiple related variables (members) of potentially different types under one logical entity.
Does defining struct student allocate memory for an instance?
No, defining a struct does not declare a new instance or allocate any memory; it only defines the type.
Where in a program should the definition of a struct type be placed?
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 do you create an instance of the struct student type?
You can create an instance by declaring it as struct student s; or struct student s1, s2;.
How do you access individual members of a struct variable?
You access members using the dot operator, e.g., s.number, s.grade, etc
What is the role of the dot operator in relation to structures?
The dot operator (.) is used to access individual members of a previously declared structure variable.
What does defining a structure do in C?
Defining a structure tells the compiler about the new type but does not allocate any storage for it.
What is the purpose of declaring a variable of a particular structure type?
Declaring a variable specifies the type and gives an identifier (name) to that variable, which allows storage allocation.
What is the primary distinction between defining a structure and declaring a variable of that structure type?
Defining a structure introduces the type to the compiler, while declaring a variable allocates memory and associates it with a name.
A binary digit is called?
a “bit”
What is the significance of the index of each byte in memory?
The index of each byte is known as its address, which uniquely identifies that byte in memory.
What is Binary?
a number system comprised of 2 digits; 0 and 1
How can you conceptualize the memory of a computer system?
The memory of a computer system can be thought of as an array of bytes connected to the processor.
How does the processor access memory locations?
The processor can access any memory location by using the corresponding addresses.
What do we call a human-readable notation
assembly language
a program that translates a symbolic version of instructions into the binary version
Assembler
the processor has a “counter” that keeps track of the
address holding the current instruction being executed
program counter (or PC)
Machine (and assembly) language is made up of?
instructions
the idea that instructions and data of many types can be stored in memory as numbers, leading to the stored program
computer
Stored-program concept
text segment
instructions reside
here
Initialized data segment
holds literals and constants in code
A data structure allows only
two operations: “push” and “pop”
stack
uninitialized data segment
contains static and global
variables
which data structure has space for automatically-allocated variables
stack
which data structure has space for dynamic memory allocation
heap
To request memory from heap
malloc()
to return the memory to heap
free()
Program translation, assembly, linking,
and loading
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
What is a process in the context of an operating system?
A process is a container for a single executable and represents an instance of a running program.
What does the operating system do regarding multiple processes?
The operating system provides a method for switching between processes and selecting the next process to run, known as scheduling.
What does switching between processes involve?
Switching between processes involves saving and restoring the program counter and many other processor status elements.
How many threads can a process have?
A process can have one or many threads.
What is a thread
a path of execution
multiprocessor architectures operate using
shared memory
multiprocessor architectures
Modern computer systems often have more than one processor