Operating Systems Midterm

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

What cloud computing environment has both private and public components? A) Hybrid Cloud B) Altocumulus Cloud C) Public Cloud D) Private Cloud E) Flying Nimbus Cloud

A. Hybrid Clouds indeed have both private and public components.

Which of the following values is the greatest? A. 2 kilobytes B. 0xA24 C. 1024 D. 0011 1011 0001 E. .0001 MB

B. In binary, this hex value is 1010 0010 0100, and through comparison with the other choices is the greatest value.

What controls the operations of the computer? A. System Bus B. Processor C. Program Counter D. Instruction Register E. I/O Modules

B. Processor is the correct answer. A processor executes operations for a computer

What visual editor was created by Bill Joy as an alternative to line editors that were operated with commands? A. ed B. Vi C. Emacs D. BRAVO E. C

B. Vi is the correct answer. It was made by Bill Joy as 1976 as an alternative to ed, a line editor that edited individual lines with commands.

What year was the original Linux released? A. 1980 B. 1970 C. 1991 D. 2004 E. 2005

C

What is the value of C if C=A&B and A and B are equal to the values 10011101 and 11101001 respectively? A. 00000000 B. 00000001 C. 10001001 D. 11101001 E. 10011101

C. This is correct because only the bits where both A and B are equal to 1, are also equal to 1 for C

Which of the following Linux command line arguments creates a new empty file called mycfile.txt? A. echo mycfile.txt B. cat mycfile.txt C. touch mycfile.txt D. mkdir mycfile.txt E. gcc mycfile.txt

C. touch mycfile.txt is the correct answer. The touch command is used to create new empty files or modify timestamps on existing files and directories. The command line argument touch mycfile.txt creates a new empty file called mycfile.txt.

Which line editor is specified in the Single Unix Specification (SUS)? A. emacs B nano C. vi D. notepad++

C. vi is the correct answer. It was inspired by the text editor BRAVO, and due to copyright issues, many other text editors, such as emacs, are inspired by vi.

What year did the government break up AT&T? A. 1974 B. 1984 C. 1969 D. 1982 E. 2004

D

Which code below sets the 1st, 3rd, and 7th bit to a 1 on the unsigned integer 247 (bit numbering, 0-7)? unsigned int num = 247; --- A. num | 0b10001010; B. ~num & 32; C. num << 0x1; D. num | 15; E. 0xFF | (num & 0b01100100)

"A" is correct because we take the variable num and perform the OR operation using bit-wise | with the binary number 0b10001010. No matter what the bit placement for the number 137 is, when we | with this binary number, bits 1, 3, 7 have to turn into a 1 no matter what.

How would you create a new directory in the terminal? A. mk dir "directory" B. Make dir "directory" C. "directory" D. touch "directory" E. mkdir "directory"

E.

Which operation will result in 0000 0001? A. 1010 0100 && 0100 1111 B. 0001 1100 & 1110 0011 C. 0011 1100 | 1000 0011 D. ~(0000 0010) E. 0100 0100 && 0000 0000

A is the correct answer as it has two true values in the logical sense (two values that are not 0) and uses the logical AND (&&) operator, resulting in any true value, hence 0000 0001.

What is the result of the following logic operation on C? A = 0xAA, B = 0xFF C = A && B A) 1 B) 0 C) 0xAA D) 0xFF E) 0xAF

A) When doing logic operators in C, the return value can only be a 1 or 0. The && operator simply checks for a valid statement, and both A and B are valid statements. The result stored in C is a 1.

What bit wise operator AND what corresponding value would you need to change the 4th bit of 1001 1101 to a 0? A. &, 0x95 B. |, 8(10) C. &, 95(10) D. |, 0x95 E. &, (0 << 3)

A. Is correct, to convert the 4th bit to a zero you must use the & bitwise operator with a number that is a copy of the existing number just with that bit changed. 0x95 is hexadecimal for 1001 0101, meaning that when you AND all the bits of 1001 1101 to it, the only bit that changes is the 4th bit.

When using void qsort (void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *)); which argument dictates how the comparison is performed? A. int (*compar)(const void *, const void *) B. void *base C. size_t nmemb D. size_t size E. cont void * F. Comparision is built into the method

A. It is the parameter that refers to a comparison method that is built to compare two different variables.

how would you compile a c file named compileFile in Linux? A. gcc compileFile.c B. vim compileFile.c C. ./a.out compileFile.c D. compile compileFile.c E. System.out.println("compileFile.c");

A. gcc compileFile.c is the correct answer. GCC stands for GNU Compiler Collection, and is the command used to compile.

Which of the following pieces of code below does NOT set bit 2 of A (where A is of type uint8_t) to 0? A. A = A & (1 << 2) B. A = A & ~(1 << 2) C. A = A & ~(8 >> 1) D. A = A & 0xFB; E. A = A & ~4;

A. is the correct option. The bitwise representation of 1 is 0000 0001, and 1 << 2 performs a right bitwise shift twice, resulting in 0000 0100. ANDing this value with A will set all bits EXCEPT for bit 2 of A to 0.

Which of the following is NOT a Bit-Wise Operator? A. || B. ~ C. >> D. | E. &

A. || is the correct answer. || is a Logical OR operator that returns a Boolean value true (1, or any other value that is not 0), if one or more condition is true, OR false (0), if all of the conditions are false.

Which of the following is not a system call? A. open() B. move() C. read() D. write() E. close()

B. 'move()' is a cmd command used on MS Windows to move/rename file, rename() is typically the syscall used to move files

Which of the following is not a reason most computer systems provide secondary storage? A. Main memory is too volatile. B. We do not want programs and data to reside permanently within the main memory, so it is stored in secondary storage so it can lose its content. C. Main memory loses its content when power is turned off. D. Main memory is usually too small to store all needed programs and data permanently. E. Secondary storage is able to hold large quantities of data permanently.

B. We do want programs and data to reside permanently, thus this is the correct answer.

Which command allows you to look up the user manual of any command that we run on the terminal? A: qsort B: man C: make D: clean E: mkdir

B. man - The man command shows the user a user manual for the command that they are trying to use ion the terminal. User needs to type $ man [command name] in order to use the man command.

What year did AT&T license away UNIX? A. 1975 B. 1973 C. 1974 D. 1969 E. 1977

C is the correct answer. AT&T was a government sanctioned monopoly. They couldn't sell UNIX, so they licensed it away.

Which command will save and close the text editor Vim? A. :q B: :w C. :wq D. s E. :sc

C.

Which Linux command would successfully append the string "The second line" into a file myfile.txt given the file already has string contents "The first line"? A. cat "The second line" >> myfile.txt B. echo "The second line" > myfile.txt C. echo "The second line" >> myfile.txt D. "The second line" >> myfile.txt E. touch "The second line" >> myfile.txt

C. is correct because ">>" would append the string to the file, given the file already has contents

If we had a set of 8 bits, 01101101 and we right shifted the bits 3 times and then left shifted 2 times, what would the new value be in decimal form? A: 13 B: 109 C: 52 D: 180 E: NULL

C: 52 is the correct answer. After right shifting 3 times, we get the bits 00001101, and then after left shifting those bits 2 times, we get 00110100. Converting 00110100 to decimal form equals 52.

According to Dr. Grant on August 25th, what was the fun fact or coincidence with the class's date? A. August 25th is celebrated as "International C Day" to commemorate the initial launch of the C programming language B. August 25th is the anniversary of the first computing system C. August 25th is the date the government broke up Bell Labs D. August 25th, 2022 was Linux's 31st birthday E. August 25th is Mexican Independence Day

D is correct. On August 25th, 1991 Linus Torvalds sent an email to people he knew inviting them to give feedback and suggestions for a new, free operating system he was creating as a hobby.

What is the oldest Linux distribution? A. SUSE B. Red Hat C. Debian D. Slackware E. Windows

D. Slackware is the correct answer and it came out in 1992

what is the correct order of memory sizes from smallest to largest? A. Terabytes, Kilobytes, Zettabytes, Yottabytes, Petabytes B. Petabytes, Kilobytes, Zettabytes, Terabytes, Yottabytes C. Kilobytes, Terabytes, Petabytes, Yottabytes, Zettabytes D. Kilobytes, Terabytes, Petabytes, Zettabytes, Yottabytes E. Yottabytes, Zettabytes, Petabytes, Terabytes, Kilobytes

D. the correct answer with kilobytes (2^10) being smaller than Terabytes (2^40) being smaller than Petabytes (2^50), being smaller than Zettabytes (2^70) being smaller than Yottabytes (2^80).

Which operating system service exchanges information between processes? A. Wires B. I/O Operation. C. Program Execution D. File-System Manipulation E. Communications

E. Communications services handle the exchange of information between processes usually by either using shared memory, or passing the formatted information to the process.

Which one below is NOT counted in primary storage? A) RAM B) Registers C) Cache D) Memory E) Hard disk drives

E. Hard disk drives -> secondary storage

Which device can be described as a "mechanism by which other modules may interrupt the normal sequence of the processor." A. Memory Address Register B. Program Counter C. Instruction Register D. Accumulator E. Interrupts

E. Interrupts is the correct answer. They are used if a high-priority process is begun during a different process running. It suspends the current process and focuses on the high-priority process (CPUs).

When compiling a .c file in Linux/UNIX using the command line, by default, which output file extension will be produced? A. mycfile.out B. mycfile.c C. mycfile.exe D. mycfile.cpp E. mycfile.java

A is correct because Linux/UNIX by default produces the executable from compiling c files into .out files. If the file was not specified to be named, the automatic file that will be produced when compiling will be called "a.out", and extra commands can be used to change the name of it.

Which is NOT one of the several ways to manage the compiling/project management process in make files? A. Invokes the assembler as part of the compiling process B. Define rules for how to create derived files C. Define dependencies D. Uses file time stamps to know what work actually needs to be done E. Only compile code that needs to be compiled

A is correct in not being one of the mentioned ways of managing the compiling/project management process of make files. As mentioned in the "Compiling Code Bases" slides, the GNU C Compiler (gcc) does this when compiling and can get tiring and error prone.

Which of these commands will take the following program "myprog" successfully?1. map "stdin" to a.txt2. map "stdout" to b.txt3. map "stderr" to c.txt A. ./myprog <a.txt >b.txt 2>c.txt B. gcc myprog <a.txt >b.txt 2>c.txt C. ./myprog <a.txt 1>b.txt >>c.txt D. gcc myprog <a.txt >b.txt >>c.txt E. myprog 0<a.txt 1>b.txt 2>c.txt

A is correct. "./" indicates the local filepath needed. The proper stderror notation is "2>".

What is the function that returns the number of bytes the variable requires? A) sizeof() B) size() C) byteSize() D) sizeOfByte()

A) sizeof() => this function returns the number of bytes the variable requires

If a and b are pointers to structures with a variable declared by: short number;, how would you compare these structure's number variable such that you get a negative number if b < a, positive number if a > b, and zero if a == b? A. return (a->number - b->number); B. return (a.get(number) - b.get(number)); C. return (a*.number - b*.number); D. return (b->number - a->number); E. return (&a->number - &b->number);

A.

What is resulting value of the following expression in C: !(0b1011 && 0b0111)? A. 0 B. 0b1100 C. 1 D. 0b0000 E. Error

A. 0 is the correct answer because && is a logical operator so it is performing boolean algebra to determine the result of the expression. In C, there is no boolean type, so any non-zero number is considered to be true when used in a logical expression. In the example, we have two non-zero binary numbers and we "and" them together, so the result of "true and true" is true, for which C returns a value of 1. We then negate the value, for which C returns 0.

Which binary string is the equivalent of ~6? A. 11111001 B. 00000110 C. 00001100 D. 00000011 E. 00000001

A. 11111001 is the correct answer. The tilde operator is the compliment of the modified number, so it is represented as the inversion of 6. Since 6 is equivalent to 00000110, the inversion is 11111001.

What will the following code snippet print? int box; box = 0xA; int *label; label = &box; *label = 0x10; printf("%d %d\n", box, *label); A. 16 16 B. 8 16 C. 10 16 D. 0xA 0x10

A. 16 16 is the correct answer. The *label pointer points to the location in memory where "box" variable is stored and alters it's value from 10 to 16.

When the user requests via the shell that the OS run an application a loader loads the executable file into memory. Section 2.6 of Operating System Concepts 10th Ed. (Silberschatz) explains that the shell first performs the ____ system call to create a new process in which the program will run. A. fork() B. exec() C. open() D. pipe() E. chmod()

A. A is correct because the fork() system call creates sub-processes. In Unix-based operating systems, init is the first process and ancestor of all subsequent processes on the system. All sub-processes are "forked" in some way from init.

Assuming all values are unsigned 8-bit values: X = 0101 1010 What is the value of Y after the following operation: Y = X | (1 << 2) A. 0101 1110 B. 0110 1000 C. 1010 0101 D. 0000 0000 E. 0001 0110

A. After the 1 is left shifted twice (0000 0100), the X (0101 1010) is OR'd with the new value. With any OR operations, all 1's are retained in place. Therefor 0101 1110 is the correct answer.

What is the order of the files in the compilation process of make files, beginning from code? A. C file, Object file, Executable file B. Object file, C file, Executable file C. C file, Executable file, Object file D. Executable file, C file, Object file E. Executable file, Object file, C file

A. C file, Object file, Executable file is the correct answer, as the C code is compiled down to object file first, which is the lower level representation of the C file that begins to map out into the actual memory (computer). It then will take the Object file and potentially other object files, if others exist with it, and combine them together to create an executable file.

What translates code from human readable to machine-specific code A. Compiler B. Object File C. C File D. Linker E. Google Translate

A. Compiler is the correct answer. The compiler is tasked with translating C files into machine-specific code giving you object files.

What is the executable command to open a calculator? A. bc B. calculator C. cat D. gcc file.c E. cal

A. From Dr. Fagg's Lecture on September 13th "So there is an executable called BC, which is a calculator."

what is the value of x and y after the following operation: int x = 5; int y = 7; x = y++ + 1; x++; A. x = 9, y = 8 B. x = 9, y = 7 C. x = 10, y = 7 D. x = 10, y = 8 E. x = 5, y = 7

A. Since y is post incremented, the value of x becomes 7 + 1 = 8. x is then incremented once to become 9. The value of y becomes 8 after the post increment;.

What is the reason for doing the memory hierarchy? A. The Principle of Locality B. Expenses, Speed, and Memory Size C. Interrupts D. To enable preprocessing, compilation, assembling, and linking

A. The Principle of Locality is the correct answer. The Principle of Locality states the memory references by the processor tend to cluster, which means that the next piece of memory that one wants will be close to the first piece of memory. Furthermore, the Principle of Locality also states that if you want memory, you may want to access adjacent levels. (1:11:16 in Lecture)

Which date is Unix time based on and who set this standard? A. - 1/1/1970 Dennis Ritchie and Ken Thompson B. - 1/1/1970 Richard Stallman C. - 1/1/1969 Linus Torvaldis D. - 1/1/1976 Bill Joy

A. The Unix Epoch time was set for 1/1/1970 because in 1969, UNIX was implemented by a team led by Dennis Ritchie and Ken Thompson at Bell Labs. The date was set to that time because it is what made sense for the engineers and time is calculated in milliseconds since that date for any UNIX-based system.

How many bytes are in a short? A. 2 bytes B. 4 bytes C. 1 byte D. 8 bytes E. 16 bytes

A. The correct answer is 2 bytes. There are also 2 bytes in ints. While the answer is not 4 bytes, there are 4 bytes in longs and floats. Chars have 1 byte and doubles have 8 bytes.

"...the end of a string character is what?" A. \0 B. \n C. \t D. \r E. \(:

A. The correct answer is A, the end of a string is the null character, which is a character with all bits set to 0.

How can 1 in decimal format be represented in Boolean logic? A. True B. False C. 0x0 D. 0x1 E. 1 cannot be represented in Boolean

A. This is correct answer because 1 is allows know to be true in Boolean.

What is responsible for moving the data between the peripheral devices that it controls and its local buffer storage? A. Device Controller B. Middleware C. Instruction register D. System Daemons E. USB cable

A. This is the correct answer as device controllers transfer data between peripheral devices to the local buffer. Usually operating systems have a device driver for each device controller.

What is the difference between & and &&? A. & is a bitwise operator, && is a logical operator B. They are both bitwise operators C. & is a logical operator, && is a bitwise operator D. They are both logical operators E. Neither & or && are valid operators

A. This is the correct answer. & compares variables bit by bit whereas && compares the boolean values of the variables.

What code is used to allocate memory on the heap for an array of 32 integers named org in C after the following code is executed? int a;int *org;org = &a; A. org = calloc(32, sizeof(int)) B. org = realloc(32, sizeof(int)) C. org = calloc(sizeof(int), 32) D. org = realloc(org, 32*sizeof(int)) E. org = free(org)

A. This is the correct answer. This allocates space on the heap for an array of 32 integers named org.

Using bit-wise operators, which code below sets the 2nd, 5th, and 6th bit to 1 on the unsigned integer 137 (bit numbering, 0-7)? unsigned int num = 137; A. num | 0b01100100; B. ~num & 32; C. num << 0x1; D. num | 15; E. 0xFF | (num & 0b01100100)

A. We take the variable num and perform the OR operation using bit-wise | with the binary number 0b01100100. No matter what the bit placement for the number 137 is, when we | with this binary number, bits 2, 5, 6 have to turn into a 1 no matter what.

What is the primary benefit of using strncpy() vs strcpy() when assigning a value to a character array? A. strncpy() is faster than strcpy(). B. strncpy() is less susceptible to memory/buffer overruns than strcpy(). C. strcpy() is only works for character arrays that are less than 5 characters long. D. strcpy() is no longer a supported function in C.

B. "strncpy() is less susceptible to memory/buffer overruns than strcpy()" is correct because, when writing to a buffer of defined size, it is important to not write character to memory locations that are not part of the buffer. strncpy() allows us to do this but strcpy() does not.

file(s) of what extension are generated during the compilation stage (before the linker stage) of a code base? --- A. .c B. .o C. .exe D. .py E. .class

B. .o is the correct answer, this type of file is generated during the compilation stage as object files, which are used by the linker.

How many bytes are in 1 kilobyte? A. 1012 bytes B. 1024 bytes C. 1000 bytes D. 1048 bytes E. 128 bytes

B. 1024 bytes or 2^10 bytes. One way to tell that this is the case is by noticing this is in the form 2n where n = 10. The other options are similar, but are not in 2n, so it is easy to tell they are incorrect. E is in 2n but it is 27 which is too small.

What Java primitive data type does not exist in C? A. Char B. Boolean C. Int D. Double E. Float

B. From the pdf page 9 "Some of Java's primitive data types do not exist in C. For example, there is no 'Boolean' type in C." To perform a Boolean operation in C it would require usually a value to be set as "1" for true and "0" for false.

What would be the value of Q after this operation: Q = R && S (Assuming 8-bit values) R: 0110 0010 S: 1010 0101 A. 0000 0000 B. 0000 0001 C. 0010 0000 D. 1110 0111

B. The correct answer is A since "&&" is the logical and operator. The value of 0 is false and all other values are true. This means R and S are both true so Q gains the value of 1 meaning true.

With reference to the Execution of a hypothetical machine, what is opcode (Operation Code) used for/as? A. It is used to compile assembly code and other programming language. B. It is used when writing machine code for identifying which operation should be performed. C. It is used as the memory location used to execute an instruction D. It is used as computer protocol commands or as a language statement that does nothing. E. It is used to optimize the code.

B. The opcode identifies which computer operation in the instruction set is to be performed

In what order does the Instruction Execution cycle function in, and what information will the RAM hold? A. Fetch, Halt, Execute; holds computing value only B. Fetch, Execute, Halt; holds instruction address and computing value C. Fetch, Execute, Halt; holds computing value only D. Execute, Fetch, Halt; holds instruction address and computing value E. Fetch, Execute, Halt; holds instruction address only

B. This answer is correct because the Instruction Execution cycle should first FETCH the value, EXECUTE the needed operands on the value through the program counter, instruction register, and accumulator, and then (after cycling through) HALT completely ends the cycle. The information used in this cycle will be the computing value fetched and the address used to store and load both data and instructions in the RAM.

What does the 'A' and 'B' in the bitwise operation "A >> B" stand for? A. 'A' is the variable whose bits get left shifted and 'B' is how many places to shift the bits B. 'A' is the variable whose bits get right shifted and 'B' is how many places to shift the bits C. 'A' is how many places to shift the bits and 'B' is the variable whose bits get left shifted D. 'A' is how many places to shift the bits and 'B' is the variable whose bits get right shifted E. 'A' tells which bit the shift will start at and 'B' is how many places the bits will shift

B. This is the correct answer because A indicates what variable will undergo the shift and B indicates how many places the bits will shift. This would be the correct syntax for the code.

Dr. Grant mentions that some warnings that show unused variables may seem benign, but actually mean that you could have what serious issue? A. Arithmetic Error B. Memory Leak C. Logic Error D. Compiler Error E. Copycat Syndrome

B. This is the correct answer. Dr Grant mentions that these warnings may not seem to be a big deal, but they can actually cause memory leaks in which can cause issues in major programs.

What is the purpose of having a user mode and a kernel mode? A. Having two modes of operation allows the system to run more efficiently as it can switch back and forth between modes best suited for the task. B. The dual mode of operation provides us with the means for protecting the operating system from errant users—and errant users from one another. C. The user mode handles system calls from the software and kernel mode handles system calls from the hardware. D. Kernel mode uses bits (0 or 1) to distinguish between a task that is executed on behalf of the operating system, the bit mode, and one that is executed on behalf of the user, the user mode. E. Kernel mode is for administrative purposes, taken from meaning of Colonel, while the user mode is for the average user who doesn't want/need to configure the specific details of their system.

B. This is the correct answer. Since the operating system and its users share the hardware and software resources of the computer system, a properly designed operating system must ensure that an incorrect (or malicious) program cannot cause other programs—or the operating system itself— to execute incorrectly.

According to the course textbook, "Operating System Concepts, 10th Edition", Section 1.2.2 "Computer-System Organization: Storage Structure", and Dr. Grant's CS 3113 lecture on September 1st over memory hierarchy and the principle of locality, the typical general-use computer runs a majority of its operations purely using main memory (also known as RAM). However, the average computer requires a secondary memory structure to function properly. The following five answer statements each justify one reason why secondary storage is crucial to computer systems. Which of the reasons are INCORRECT? A. Main memory is too costly and resource-heavy to use for both permanent data storage and quick, constant I/O operations. B. Secondary storage devices can aid in running slower, more complex programs to allocate access times accordingly across storage processors. C. Main memory cannot store information reliably due to its volatility, warranting another memory structure to store more permanent data. D. Secondary storage allocates more permanent data in a high-capacity storage unit, sacrificing rapid access time as these data are infrequently edited. E. Allocation of storage systems based on the storage-device hierarchy in Figure 1.6 divides resources most sparingly for the best possible computing power.

B. This is the correct answer. This justification is NOT correct. Secondary storage devices are not intended to aid the main memory structure in holding volatile storage. Since it has a much lower speed and longer access time, it would be a misapplication of resources to have it perform the function of the RAM, registers and cache. This answer highlights a fundamental misreading of the following sentence on page 13 of the textbook: "most computer systems provide secondary storage as an extension of main memory." By extending main memory, the secondary storage helps with data storage and does not necessarily take on the same memory as the main memory. The storage-device hierarchy debunks this by dividing memory by what types of data are best suited for each device, based on factors like size, speed and resource cost.

Which of the following is NOT a Automatic Variable used to construct a Makefile? A. $* B. $@ C. $~ D. $< E. $^

C. $~ is the correct answer. Unfortunately, $~ is not a real Automatic Variable and when compiling the shell will throw a syntax error.

What is the binary code and logical operation that allows us to set bit 2 of A to 1 without changing the other bits around it? (we start counting bits from 0) A. 11111111 B. 11111011 C. 00000100 D. 00000000 E. 10101010

C. 00000100 is the correct answer. It is the correct answer because when using the logical operator OR the bit 2 spot will return 1 no matter one since the binary code has a 1 in that spot

which of the following commands allows changes to be added to a GitHub repository from a local repository? A. Git commit B. Git add C. Git push D. Git config E. Git clone

C. Git push pushes committed changes from a local repository to a GitHub repository.

Which of these types of memories is volatile storage? A. SD cards B. Hard disk drives C. RAM D. Flash drives E. Internal hard drive

C. RAM holds information temporary, the stored memory is lost as soon as the power supply is interrupted - therefore it is volatile storage.

What immediately happens when a CPU receives an interrupt? A. The I/O device will finish the previous transfer B. The I/O device receives another I/O request C. The CPU will stop executing the current program D. The CPU will resume the task that was interrupted E. The GPU creates an interrupt vector

C. The CPU will stop executing the current program is the correct answer. An interrupt is a signal emitted by a computer/program that requires the OS to stop temporarily. When the CPU is interrupted, it stops what it is doing and will transfer the execution to a fixed location.

Why are the Registers the closest to the CPU? A. So they are able to access the CPU's buses B. To save money on the wires connecting them to the CPU C. They are the only chip small enough to fit close to the CPU D. The data in the registers is accessed a lot E. Mcmuffin

D. The information in the registers are very important and get accessed a lot

Which of the following statements are NOT true based on of the principles of locality? A: Data is organized so that the percentage of access to each successively lower level is substantially less than that of the level above B: Memory references by the processor tend to cluster C: Data is accessed more often on each successively lower level than that of the level above D: The principles can be applied across more than two levels of memory

C. The correct answer is this because it directly violates the second part of the law of locality we covered in class, which states that the percentage of access to each successively lower level is substantially less than that of the level above

Which Linux command would successfully redirect the string "The First Line" into the file myfile.txt --- A. "The First Line" < myfile.txt B. echo "The First Line" < myfile.txt C. echo "The First Line" > myfile.txt D. "The First Line" > myfile.txt E. cat "The First Line" > myfile.txt F. echo cat "The First Line > myfile.txt

C. echo "The First Line" > myfile.txt is the correct answer. The ">" is used to redirect the output of the echo to the file, replacing its contents. ">>" would append the string to the file's contents.

What are the advantages of using tape dives as a medium of data storage? A. While not the fastest, tapes drives are able to outpace SSDs and are less expensive than SSDs. B. They are one of the fastest mediums for transferring data to a computer. C. They are one of the cheapest mediums and are faster than using the cloud. D. They are highly expensive, but relatively small E. Tape drives are obsolete and should not be considered to be used in the modern day.

C. tape drives are the second cheapest memory medium, but are the second slowest medium on Grant's memory hierarchy.

On which language Unix was rewritten on the year 1973? A. SQL B. C++ C. Java D. C E. C#

D.

In the main function declaration: int main(int argc, char** argv, char** envp) { ... }, what is the "char ** envp" argument? A. The number of environment variables B. An array of the command line arguments C. The number of command line arguments D. An array of environment variables E. An array of bytes

D. "char** envp" refers to an array of environment variables.

How would you run a c file named myCProgram.c? Assume the program has already been compiled and no output program name was defined. A. ./a.out.c B. ./myCProgram.c C. gcc myCProgram.c D. ./a.out

D. ./a.out is the correct answer. When a program is compiled in Linux, the default executable created is called a.out, this is an abbreviated name for assembly output. ./ stands for current directory and running the command ./a.out will run myCProgram.c by reading the translated assembly code created by the compiler.

Given the following Makefile, which of the following commands would not execute as a result of the "make all" command? A. hello.o: hello.c B. hello.exe: hello.o C. hello.c D. clean: E. all: hello.exe

D. Clean will not run for the command "make all". This command runs for the command "make clean"

Why would we want to use cloud storage if registers are so much faster? A) Easier access for the user B) Smaller physical size C) It is on board memory D) Cheaper storage E) More expensive storage

D. Cloud storage is much cheaper than registers, so you can use it to hold large amounts of storage.

Which of the following is an incorrect use of arrays in C? A. int a1[5]; B. int a2[] = { 1, 2, 3 }; C. void foo(int a[]) { a[3] = 0; } )int [] a4 = { 1, 2 };

D. Has the wrong notation and an error will be given.

What does left shifting (<<) by k bits do? A. Subtracts 2^k from a binary number B. Divides a binary number by 2^k C. Adds 2^k to a binary number D. Multiplies a binary number by 2^k E. Inverts the bits

D. Multiplies a binary number by 2^k is the correct answer. When left shifting (<<) by k bits, you are multiplying the binary number's decimal form by 2^k.

Which form of memory is the closest to the CPU, and therefore the fastest? A. Solid-State Drives B. Main Memory C. Tape Drives D. Registers E. Cloud/Network Storage

D. Registers is the correct answer. Registers are the type of memory that is directly connected to the CPU, making them the fastest option due to the speed of data travel being limited to the speed of light.

Who created the GNU Linux project in 1984? A. Lynne Jolitz B. Bill Joy C. Dennis Ritchie D. Richard Stallman E. Ken Thompson

D. Richard Stallman. In 1984, Richard Stallman started creating the free UNIX, he started GNU.

What is the correct order for generating an executable file? A. preprocessing, compilation, linking, assemble B. linking, assemble, compilation, preprocessing C. compilation, preprocessing, assemble, linking D. preprocessing, compilation, assemble, linking E. all files are directly executable by the CPU

D. The preprocessor must modify the source code before compilation takes place. The compiler then translates from human readable to machine specific code. In the assemble phase, assembly instructions are translated into object code. Lastly, the linker brings together multiple object files so that all functions are known. Generating an executable file must be done in this order.

Which of the following describes an object file? A. Defines dependencies and rules to generate derived files B. Translates from human-readable code to machine-specific code C. Brings together multiple object files so that all functions are known D. An intermediate machine-specific representation of what is in a C file E. A non-executable containing characters like numbers, letters, symbols, etc

D. This best option best describes an object file. It is what a C file is converted into after it is compiled.

Which of the following operators is used to shift left? A. < B. || C. >> D. << E. !

D. This is the correct answer. "<<" is used to perform a bitwise shift left.

Ubuntu, a popular Linux distribution, is based on which other Linux distribution? A. Suse B. Xubuntu C. Arch linux D. Debian E. Mac OS

D. Ubuntu is based on the Debian GNU/Linux distribution.

what is the correct term for 260 bytes? A. yottabyte B. petabyte C. terabyte D. exabyte E. wholelottabyte

D. exabyte is the correct answer, it is the term for 260 bytes or 1,152,921,504,606,846,976 bytes.

What is the correct conversion of the binary number 10011 to a decimal number? A. -23 B. -19 C. 13 D. 23 E. 19

E. 19 is clearly the correct answer because we have ones in the 16s spot, the 2s spot, and the 1s spot, so we just add 16 + 2 + 1 to get our answer of 19

What is the standards used by the C programming language? A. IEC B. ISO C. IEEE D. W3C E. ANSI

E. American National Standards Institute (ANSI) is the standard that all Unix systems implements. Providing C89, C99, C11, and recently C18

Which one is not the general architecture of MacOS and iOS? A) User experience layer B) Kernel environment C) Core frameworks D) Application frameworks layer E) JNI

E. JNI: Correct answer, Android developers write Java programs that use the Java native interface which is JNI and it is not used by macOS and iOS

Which of these is a group of standards developed to promote source code portability? A: VIM B: UNIX C: GNU/Linux D: TMUX E: POSIX (Portable Operating System Interface (X for UNIX))

E. POSIX (which stands for Portable Operating System Interface) is a set of standards implemented primarily for UNIX-based operating systems. It is also a group of standards developed to promote source code portability.

Referring to the memory hierarchy discussed in Lecture 4, what factors increase as you move up the pyramid? A. size and memory density B. cost, speed, and size C. speed and memory density D. cost and size E. cost and speed

E. The cost and speed of the memory storage components increase as you move further up the pyramid. Simultaneously, their size decreases. The lower down the pyramid you go, you decrease the performance in manipulating data. However, you could save on costs and also increase memory density by moving down the pyramid.

What does the argument argc in the main method of your C program contain? A. he number of arguments in the main method B. An array of command line arguments C. An array of environment variables D. The current user of the machine E. The number of command line arguments

E. The number of command line arguments is the correct answer. This information is important to know so we do not have an out-of-bounds error when accessing the command line arguments.

What is the result of writing 01011110 & 10011011 in a C program? A. NULL B. 11011111 C. 1 D. 0 E. 00011010

E. This is the correct answer because the symbol '&' represents the AND bit operation. The two bytes would compares each bit and if both are ones the bit in the resulting byte would be a 1. In any other case it would be a 0

What is the proper bit-wise operator to use if you want to a specific bit of a binary number to a '0' value while leaving the rest of the numbers unchanged? Example: What operator would you use to change the fourth bit of a random 8 bit binary number to '0' while leaving the rest unchanged? A. Shift Right B. OR C. XOR D. NOT E. AND

E. Using the bit-wise AND operator is the correct answer. As the above example says, if you would like to set the 4th bit (from the right) of an 8 bit binary number to zero while leaving the others unchanged, you would use the bit-wise AND of the original number and '1111 0111'. A bit-wise AND of any number and '0' is always zero, while a bit-wise and of any number and '1' is always the original number. For any binary x, x&0 is always 0, while x&1 is always x, meaning that when we AND each original bit with '1', we simply get the original bit.

Which of these interrupts is a maskable interrupt? A. memory error B. invalid opcode C. floating-point error D. divide error E. input available from keyboard

E. is the only maskable interrupt. The others are all critical errors that cannot be delayed, while reading in input from a keyboard can be delayed while executing critical instructions.

What is the outcome of running the make command with the following make file? all: mycfile mycfile: mycfile.o gcc -o mycfile mycfile.o mycfile.o: mycfile.c gcc -c mycfile.c pdf: mycfile.c enscript -r2 mycfile.c -o mycfile.c.ps ps2pdf mycfile.c.ps clean: rm mycfile.o mycfile *.ps *.pdf A) creates the object file mycfile.o, then prints the output to mycfile B) runs the program outputting to the console C) creates the object file mycfile.o, then prints the output to mycfile, then is creates a pdf of mycfile and then will remove mycfile.o mycfile D) creates the object file mycfile.o, then prints the output to mycfile, then is creates a pdf of mycfile E) creates the object file mycfile.o, then is creates a pdf with the output

a) it runs the command gcc -c mycfile.c which will create mycfile.o then runs the command gcc -o mycfile mycfile.o which prints outputs of mycfile.o to mycfile

Quick Sorting is an integrated method in the C language and is referred to as qsort(). This qsort() method has 4 parameters, what are they (in order)? --- a. Base pointer, number of items in array, size (in bytes) of each of the elements, and a comparison function b. Number of items in array, size (in bytes) of each of the elements, a base pointer, and a comparison function c. Base pointer, Number of items in array, a comparison function, and a comparison function return value d. Base pointer and number of items in arrays e. No parameters

a. A is the correct answer because we need a base pointer to start at the first element of the array, the determined number of elements that will run through by the base pointer, the size of each element in the array, and a function that will compare two elements to judge which is larger, smaller or equal (all parameters in this order).


संबंधित स्टडी सेट्स

CH. 8: The Chemical Senses Taste & Smell

View Set

Principles of Macroeconomics Chapter 6

View Set

Functions of the Skeletal System

View Set

Primerica Chapter 3: Life insurance policies

View Set

CompTIA A+ 1002 (Core 2) - Sections 4.4 to 4.6

View Set

I. ABDOMINAL REVIEW - 12. The Face & Neck

View Set

Med Surg Acid Base, Fluid, Electrolyte

View Set