1/23
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
What does “compiling” a program do?
Converts the human-readable code of the .c file to computer-readable code so that it can be executed.
#include <stdio.h>
int timestwo(int n) {
return n * 2;
}
int main() {
int my_number = 42;
int my_result = timestwo(my_number);
printf(“%d times two is: %d\n”, my_number, my_result);
if (my_result > 50) {
printf(“That’s a big number!\n”);
}
}
If you compile and execute this program, what output would you see?
42 times two is: 84
That’s a big number!
#include <stdio.h>
int times(int x, int y) {
return x * y;
}
void is_big(int n) {
if (n > 10)
printf("%d is a big number!", n);
else
printf("%d is NOT a big number!", n);
}
int main(int argc, char *argv[]) {
char letters[] = "abcdefghijklmnopqrstuvwxyz";
int n1 = atoi(argv[1]);
int n2 = atoi(argv[2]);
int product = times(n1, n2);
int sum = 0;
for (int i = 0; i < 5; i++) {
sum += (i * 2);
is_big(sum);
printf(" '%c'\n", letters[i]);
}
printf("End. product=%d sum=%d letters='%s'.\n",
product, sum, letters);
}
This program is called test.c ; What output would it produce, if compiled and invoked like this:
$ gcc -o test test.c
$ ./test 12 4
0 is NOT a big number! 'a'
2 is NOT a big number! 'b'
6 is NOT a big number! 'c'
12 is a big number! 'd'
20 is a big number! 'e'
End. product=48 sum=20 letters='abcdefghijklmnopqrstuvwxyz'.
Is a printer a shared or exclusive I/O device?
Exclusive; otherwise one person’s output would interleave with another person’s.
Is a computer mouse a shared or exclusive I/O device?
Exclusive; otherwise more than one program would respond to mouse movements and clicks.
Is a disk a shared or exclusive I/O device?
Shared; more than one program can write to the disk (to different files) at a time, and multiple programs can read from files on the disk at the same time.
Is a keyboard a shared or exclusive I/O device?
Exclusive; otherwise more than one program would respond to the information typed in.
What was different between the “vacuum tubes” and “transistors, batch” stages?
In both phases, computers were enormous and expensive. Small number of computers, large number of people using them (but only one at a time).
Change: The computer still only processed one person’s “job” at a time, but the invention of the “batch monitor” (really the first operating system) made it much faster and more convenient since programmers could load up their job at any time, and the machine would process it whenever there was availability. Previously, the first job would just end, and then the computer would wait idle until the second person arrived and switched the system over to their programs, so there was lots of waiting around for the humans to do their thing.
What was different between the “transistors, batch” and “ICs and multiprogramming” stages?
Machines became capable of running programs from more than one person at the same time (well, not truly “same” time but it gave that appearance).
Enabled large numbers of people to interact with a single computer at the same time. Each user could get work done.
Technical advance: integrated circuits allowed having a much larger number of switches/connections than before (individual transistors). Security/protection capability; protecting one person’s data from another, protecting one person’s running programs from another person’s.
What was different between the “ICs and multiprogramming” and “personal computers” stages?
Computers became much cheaper ($1K’s, instead of $100K’s)
Focus shifts to empowering office worker productivity and placing computing capability into the hands of the masses
What was different between the “personal computers” and “mobile computers” stages?
Cost of personal devices continues to fall making them even more common
Previously, 1 computer per person was the norm. In the “Mobile Computers” era, it is very common for a person to own several devices
Interaction model: user sometimes interacts with programs/data directly on their device (like the PC phase) but more often directly interacts with an app or web browser on their device, which is in turn connecting to the network where all the real work is happening (in the cloud).
Many new capabilities can be offered because specialized hardware/software/systems can exist “in the cloud” and ordinary users can connect to them easily.
Define registers:
Remembers values while they are being manipulated
Define memory:
Stores value persistently
Define cache memory:
Ultra high speed memory, built into the CPU; stores the most recently accessed values
Define CPU:
Executes instructions by doing forever “get the next instruction, decode it, and execute it”
Define program counter:
Keeps track of the next thing to do (next instruction to execute or next operand to fetch)
Repetitive tasks are often done more quickly using a _______ interface
Command-line; particularly one that supports “scripting” where all the needed commands can be gathered into one file (called a “batch” file on Windows or “shell script” on UNIX/Linux
One time tasks are often easier to perform using a _____ (type of interface).
GUI (guided user interface) (such as windows)
On a system where the user does not have deep experience, ____’s are often the best choice since they provide step-by-step guidance as to how to complete common tasks (on-screen prompting, “help” pages, etc)
GUI (guided user interface)
Process Management (System Calls)
These calls provide the ability to launch programs and control them (for example, terminate them). An example would be the GUI feature which is used to launch a new program (on Windows, the “Start” menu or on Linux or MacOS, the bar at the side or bottom). When the user selects a program from one of these, that component calls the fork() system call to create a new process and tell it to run the program which the user requested.
File Management (System Calls)
These services are used to manage files; for example, create new files, open files for reading or writing, etc. For example, if a program needs to read a file, it would call ‘open()’ to open it, then call read() repeatedly to read the file’s contents, then call close() when it was done reading.
Directory and File-System Management (System Calls)
These calls provide functions to make and delete directories, mount and unmount filesystems, etc. An example of this is that on most OSs when the user inserts a CD-ROM or DVD into their drive, the system calls mount() to access the disk and make it available at a specific file-path.
Miscellaneous (System Calls)
This category contains several methods to do things like change the process’ current working directory, change a file’s permissions, terminate a process, and access the current system time. An example of this usage would be a program which wants to display a time-of-day clock for the user. This program would call the ‘time()’ method, then translate the results into the right time coordinates for display to the user.
Was the "monolith” operating system structure stable and reliable?
No; without clear separation of responsibility between components, one component’s code could easily overwrite another component’s data and cause a system-wide crash.