Computer Science Past Paper Questions PDF
Document Details
Uploaded by Deleted User
Tags
Summary
This document contains a set of computer science questions related to topics such as computer architecture, process scheduling, memory management, and file structures. The questions are formatted for a past paper exam.
Full Transcript
**A** **Which computers are designed for complex computations, large user groups, and networked databases?**\ A) Mainframes\ B) Supercomputers\ C) Workstations\ D) Minicomputers **What is the state of a process when it has all required resources but is waiting for CPU allocation?**\ A) Created\ B)...
**A** **Which computers are designed for complex computations, large user groups, and networked databases?**\ A) Mainframes\ B) Supercomputers\ C) Workstations\ D) Minicomputers **What is the state of a process when it has all required resources but is waiting for CPU allocation?**\ A) Created\ B) Executing\ C) Waiting\ D) Ready\ E) Blocked\ F) Blocked and waiting **\-\--Which process scheduling method is used in batch processing systems?**\ A) First come, first served (and SPF\...)\ B) Cyclic scheduling\ C) Priority scheduling\ D) Lottery scheduling **What type of address specifies a location independent of the memory\'s actual physical address?**\ A) Logical address\ B) Relative address\ C) Physical address **\-\--For page-based memory organization, what would the page number be if the logical address is 1011110110110011, with a page size of 1 KB (2^10^ bytes), and the address space uses 16 bits?**\ A) 000001\ B) 000010\ C) 011110\ D) 111111 *(Explanation: The page number is derived from the high-order bits. The logical address divided by the page size (1024 bytes, or 2102\^{10}210) gives the page number. The first 6 bits 011110 correspond to the page number in this case.)* **\--What file structure allows determining the file\'s location on the operating system?**\ A) Sequential file//sequence of bytes\ B) Indexed file//sequence of record\ C) Tree file//entries tree *(Explanation: A tree file structure organizes entries hierarchically, which facilitates locating files.)* **What storage method is used for CD/DVD devices?**\ A) Continuous file layout\ B) One-way list\ C) One-way list and memory table\ D) Single blocks *(Explanation: CD/DVD devices use continuous file layout to read data sequentially.)* **What is not performed during disk formatting?**\ A) Identifying bad blocks +clean up disk\ B) Testing all sectors\ C) Rearranging all data to reduce fragmentation *(Explanation: Disk formatting prepares the disk for use by creating file systems and testing sectors but does not rearrange data.)* **\-\--What memory protection method ensures that each program operates only within its allocated memory area?**\ A) Individual cell protection\ B) Key-based protection\ C) Register ribbon protection *(Explanation: Key-based protection uses keys associated with memory areas to enforce boundaries.)* **\--Which virtualization technologies allow using an unmodified operating system?**\ A) Full virtualization at the OS level\ B) Para-virtualization at the OS level\ C) Full virtualization and para-virtualization **B** **To which class of computers do computer clusters and grids belong?**\ A) Mainframes\ B) Supercomputers\ C) Workstations\ D) Minicomputers **What is the state of a process when it is waiting for an event from an I/O device?**\ A) Created\ B) Executing\ C) Waiting\ D) Ready\ E) Blocked\ F) Deferred **Which scheduling method allocates processing time proportionally to each user?**\ A) First come, first served\ B) Cyclic scheduling\ C) Priority scheduling\ D) Lottery scheduling\ E) Guaranteed scheduling\ F) Fair scheduling **What type of address specifies a location relative to the beginning of the program?**\ A) Logical address\ B) Relative address\ C) Physical address **\-\--In page-based memory organization, what is the page number if the logical address is 1011101111101110, the page size is 256B=2^8^ , and the address space uses 16 bits?**\ A) 00000101\ B) 00000010\ C) 01111000\ D) 11000011\ E) 11011111 *(Explanation: The logical address divided by the page size (256 bytes, or 282\^828) gives the page number. The first 8 bits 01111000 represent the page number.)* **What file structure allows multiple data blocks to be used to store a single file?**\ A) Sequential file//sequence of bytes\ B) Indexed file//sequence of records\ C) Tree file//entries tree *(Explanation: Indexed file/sequence of records structures use pointers to locate multiple data blocks, enabling flexible storage.)* **\-\--What storage method is used for CD/DVD devices?**\ A) One-way list\ B) One-way list and memory table\ C) Single blocks//I-nodes *(Explanation: CD/DVD devices typically use a one-way list to store data sequentially.)* **Which disk scheduling method serves requests in the order they are received?**\ A) FCFS (First Come, First Serve)\ B) SSTF (Shortest Seek Time First)\ C) SCAN\ D) C-SCAN **Which RAID levels allow data recovery in the event of a single disk failure?**\ A) RAID level 0 and RAID level 5\ B) RAID level 1 and RAID level 4\ C) RAID level 1 and RAID level 0 *(Explanation: RAID 1 uses mirroring, while RAID 4 uses parity to recover from a single disk failure.)* **Which virtualization technology allows a virtual machine to communicate with a hypervisor using a specialized API?**\ A) Full virtualization\ B) Para-virtualization\ C) Operating system-level virtualization *(Explanation: Para-virtualization provides a specialized API for optimized communication between the guest OS and hypervisor.* *1,***Supercomputers** - are used for particularly complex calculations (Grand Challenge calculations). **Supercomputers** can be various: A computer servers in a room Description automatically generated![A collage of a computer server room Description automatically generated](media/image2.png) **Mainframes** are for complex calculations, serve for large groups of users and etc. More than half of all data in the world's information systems is stored on mainframe computers. Classic mainframes - IBM/360, IBM/370, IBM S/390. One of biggest mainframe is IBM System z9, System z10, zEnterprise 196. A black computer server with a blue strip Description automatically generated ![A black computer tower with a white background Description automatically generated](media/image4.png) A desktop computer with a keyboard and mouse Description automatically generated Other computers: Laptops Tablets Network computers; 2. - **Created** The state when a process is created. - **Running** The active state, where the process has all the necessary resources and is executed by the processor. - **Blocked** A passive state where the process is waiting for some event or resource to proceed. - **Ready** A passive state where the process has all required resources and is waiting for a processor to execute. - **Suspended** The process is moved to disk to free up memory for other processes. 3. *Batch processing systems* **First-Come, First-Served(FCFS))** ![A chart with numbers and a few steps Description automatically generated with medium confidence](media/image6.png) **Shortest-Job-First(SJF)(SPF)** Process planning is done taking into account the duration of the process. Two schemes: - Scheme 1: Uninterruptible - If a process is allocated CPU time, the process cannot be terminated until it has finished. - Scheme 2: Interrupted - if the time of the new process is shorter than that of the active process, then the shorter one is executed. Also called Shortest-Remaining-Time-First (SRTF). A colorful rectangular boxes with text Description automatically generated with medium confidence **3.** **Round-Robin Scheduling//cycle planing** - Each process receives a quantum of CPU time - The time quantum is usually 10-100 milliseconds. - After that, the process is moved to the end of the queue. - n - number of processes, q - quantum of time. Each process takes 1 n CPU time - The waiting time of the process is no longer than (n − 1) · q. - Important choice of quantum size: - If q is too large - response time is long; - If q is too small - a lot of time is wasted in switching. **Priority scheduling: general rules** - The scheduler can select a process with a higher priority for execution. - can be used for many queued ready processes that correspond to different process priorities. - Example: the shortest process is served first - here the priority is determined by the next required (planned) CPU time. - Problem ≡ starvation - low priority processes may never run - Solution ≡ aging - increase process priority over time. **Priority scheduling** ![A diagram of a running process Description automatically generated](media/image8.png) **Priority scheduling:HRRN (Highest Response Ratio Next)** A black line with numbers Description automatically generated![A table with numbers and words Description automatically generated](media/image10.png) The process with the highest value of this ratio is selected for service. No starving (estimated aging) Suitable for short processes. **Priority Scheduling: Multilevel Queuing** - The queue of ready processes is divided into separate queues - interactive and background processes. - Each queue has its own process scheduling discipline - interactive - RR, background - FCFS. - Planning must also be done between rows. - Fixed, service all interactive processes first, then background. Starvation is possible. - Another solution is to apply the principle of time quantization to each queue - each queue receives a part of the CPU time and divides it among the processes in the queue. Eg. 80% for interactive with RR discipline, and 20% for background with FCFS discipline. **Prioritetinis planavimas: daugelio lygiu˛ eile** A diagram of a process flow Description automatically generated **Lottery Scheduling** - Lottery tickets are distributed to processes, which allow them to use resources. The more tickets a process has, the more CPU time it can use. - (Eg. If there are 100 tickets and Process A has 20 tickets, then it owns 20% of the CPU time) - Used for multimedia systems, video servers. This way it is possible to use different download speeds for different users (10,25,\...) **Fair Planning** - Vart A creates - 9 Processes - Vart B creates - 1 Process - We perform cyclic planning: - Vart A - 90% CPU time - Vart B - 10% CPU time - Some systems take into account the number of goal scorers and then divide, for example: 2 users each get 50% of the CPU time - User A creates - 4 Processes (A,B,C,D) - User B creates - 1 Process (E) - If the system takes into account the number of users and then divides it into equal parts: (2 users get 50% CPU time each) - A E B E C E D E A E B E C E D E\... - If we allocated twice as many resources to Vart A, we would get this - A B E C D E A B E C D E\... - There are more options for fair planning. 4. **A logical address** is a reference to a memory location independent of the current data location in memory: to gain access to a memory cell, it is necessary to transform the logical address into a physical one. **A relative address** is a special case of a logical address, when the address is defined from a certain predetermined point (usually the beginning of the program). - If a program uses relative addressing, it means that all references to memory in the current process occur from the beginning of the program. Hence, mechanisms (at the hardware level) are needed to transform relative addresses into physical ones. **Physical address** (or **absolute**) is the direct address of a physical memory cell. 5. ![](media/image12.png) **Logical addresses** - Relative address: 1502, in binary we get the number highlighted in yellow. Since 16 bits are reserved for addressing, we add 5 zeros to the front. - - Page size: 1KB = 1024B = 210 - The degree indicates that the offset will require 10 Bits. - There are 6 bits left per page, which is 26 = 64 pages. - Page = 1 Offset = 478 - ![](media/image14.png) - Check: 1024+478=1502 - Relative address: 1502, in binary we get the number highlighted in yellow. Since 16 bits are reserved for addressing, we write 5 zeros in front. - - Page size: 256 B = 28 - The exponent indicates that the shift will require 8 bits. - There are 8 bits left per page, which is 28 = 256 pages. - Page = 5 Offset = 222 - ![](media/image16.png) - Check: 1024+478=1502 - Relative address: 1502, in binary we get the number highlighted in yellow. Since 16 bits are reserved for addressing, we write 5 zeros in front. - - Page size: 2 KB=2048 B = 211 - The exponent indicates that the offset will require 11 bit. - There are 5 bits left per page, which is 25 = 32 pages. - ![](media/image18.png) - Check: 0+1502=1502 6\. Sequence of bytes Sequence of records Record tree **Sequence of bytes** A tall rectangular object with a black border Description automatically generated with medium confidence **Sequence of records** ![A rectangular object with black lines Description automatically generated](media/image20.png) **Record tree** A diagram of a diagram Description automatically generated with medium confidence 7. **Continuous arrangement of files** Use in CD-ROM, DVD,\... ![A diagram of a file Description automatically generated](media/image22.png) **One-way list** A diagram of a file block Description automatically generated Advantages of the method: - Blocks can be anywhere in memory; - Only one block 1 address needs to be stored in the directory. Disadvantages: - If we need to refer to block 9, the OS must read block 8. Understandably, such a scheme will be slow. - Block pointer requires 2 bytes. OS reads in larger blocks 512B 1024B, 2048B. This means that to access block 9, you will need part of each block, even though only 2 bytes of real information will be needed. This problem disappears if we put the pointers into an in-memory table. **One-way list and memory table** ![](media/image24.png) Disadvantages: - FAT table is stored in RAM and contains all files; - All file pointers are mixed in one table. For example: - 20GB - disk; - 1KB -- block size; - Table size: 20 million records. - Record size min= 3B, if we want more efficient search 4B; - The table will be: 60MB or 80MB - If this table doesn't fit in memory, then we could use virtual memory, but how much will it cost to transfer from/to RAM. Advantages: - A particular I-node must be in memory when the corresponding file is open. - Ex. Each node occupies n Bytes, and K files can be opened simultaneously in the system, which will require K\*n Bytes. Regardless of whether the disk size is 1GB or 10GB. - This is significantly less than FAT. Because the size of the FAT table is proportional to the size of the disk. Because FAT stores a list of all memory blocks. Disadvantages: - A fixed amount of addresses is allocated for each file, which may not be enough. - One of the solutions: reserve the last block not for data, but for an additional block of addresses. As shown in the picture. A diagram of a computer server Description automatically generated 8. **A.**Disk formatting means writing data to all sector addresses. During formatting, data is written and read to all sectors in order to: - Clean up disk - Test all sectors - Identify bad blocks - - FCFS - First-come, first-served - SSTF - Shortest seek time first - SCAN -- scan one direction, then the other - C-SCAN -- scan in one direction only **FCFS - First come, first served** ![A graph with lines and numbers Description automatically generated](media/image26.png) **SSTF** A graph with numbers and lines Description automatically generated **SCAN**![](media/image28.bmp) **C-SCAN** *9.A* **Moving** ![](media/image30.png) **Protection** - Each process must be protected from unwanted interference by another process. - The code of other processes must not be able to access the data of the given process for reading or writing - The relocation capability complicates this security condition because the location of the program in main memory is unpredictable, and compile-time checking of absolute addresses is impossible. - During the execution of the program, it is necessary to check all memory accesses, in order to determine that these accesses are intended only for the data of the given process. **Common Use** - Every security mechanism must be flexible enough to allow multiple processes to access the same memory location. - For example, if multiple processes are executing the same machine code, it is useful to let the processes work on a single copy of that code rather than creating their own. - Multiple processes performing a common task may require the same data. **Logical organization** Modules can be created and compiled independently of each other and references from one module to another are allowed during system program execution. - Different modules can have different protection levels (read only, execute only) - Ability to use mechanisms that allow multiple processes to use the same module at the same time. **Physical organization** All computer memory can be divided into two parts: - primary (RAM memory) - supports very high data access speed, but relatively high cost and does not support long-term data storage. - secondary (disk memory) - significantly slower, but cheaper and data can be stored permanently. It is used for long-term storage of programs and data, while the primary memory of significantly smaller capacity is used for the storage of currently running programs and their data. - The main task of the system is to transfer information between primary and secondary memory. - The programmer cannot perform this task due to the following circumstances - the main memory may not be enough for the program and its data. - In this way, the programmer must use so-called overlays, during which some modules are not loaded into the main memory, but appear in it only when this module is needed. However, this method requires additional time - In multi-program OS, the programmer does not know how much memory will be allocated for his program and where the program will be placed. - In this way, it is clear that the task of transferring information between primary and secondary memory is assigned to the operating system. This task is the essence of memory management. *9**.B*** **RAID Level 0** A close-up of several cylinders Description automatically generated - Disk array, when a logical disk is formed from separate partitions on different disks. - Block/group i is on disk (imodn) - Advantages - Read/Write n blocks in parallel; bandwidth increases by n times - Disadvantages: - No data duplication. - The probability of a system failure is equal to 1/n the probability of a disk failure **RAID Level 1-- Striping and Mirroring** ![](media/image32.png) - Each section is written twice. - Block/group i is on disks (imod2n) & (i + nmod2n) - Advantages: - Read/Write n blocks in parallel; bandwidth increases by n times - A failed disk can be replaced with another one after copying the data. - Disadvantages: - Many additional disks are required **RAID Level 4 - Parity Disk** A grey cylinder with black text Description automatically generated - parity 0-3 = stripe 0 xor stripe 1 xor stripe 2 xor stripe 3 If one disk fails, it can be restored from other disks - For example: stripe 1 = stripe 0 xor stripe 2 xor stripe 3 xor parity 0-3 - Advantages: - N times higher reading speed - A broken disk can be restored \"on-the-fly\" (hot swap) - Quick extension: just plug in a disk that would be filled with 0 values - Disadvantages: - Write speed 1X **RAID Level 5 -- Distributed Parity** ![A grey cylinder with black text Description automatically generated](media/image34.png) - RAID 5 --- an array characterized by independent access, data division into separate disks, parities distributed across the disks. - RAID 5 does not have a dedicated disk for parity, and writes parity information to all disks. - In a RAID 5 array, reading and writing can take place independently and in parallel. - RAID 5 demonstrates very good performance for reading and writing random data in small blocks. **JBOD** Disk array formation can be done not only by the RAID principle. For this, the so-called JBOD (Just a Bunch Of Disks) method can be used, when a virtual disk is formed by connecting all disks of the array to one another. Unlike RAID 0, this method does not use a block to form a solid space, but simply connects one end of the disk to the beginning of another. Therefore, only a larger capacity of the virtual disk is obtained, while there is no read or write acceleration here. Combining JBOD can be understood as the opposite of partitioning, i.e. partitioning divides a physical disk into two or more virtual disks, while JBOD combines two or more physical disks into a single logical disk. JBOD pooling is sometimes used to connect several disks of different capacities, which is completely impossible with a RAID disk array. For example, JBOD can combine 100 GB, 150 GB, 300 GB drives into one logical 550 GB drive. ***10.*What is virtualization?** Virtualization is a technology that allows computer hardware to be presented as software. Virtualization makes it possible for several operating systems to run simultaneously on one computer. Each operating system is individual and works as if it were installed on a separate physical computer **Virtualization technologies** Virtualization technologies are divided into two groups: Resource virtualization, when connecting or separating only a certain part of computer equipment (hard drives, network cards) Platform virtualization is a technology that separates the operating system from the hardware part of the computer by simulating it. Platform virtualization is further divided into: Hardware emulation Full virtualization Paravirtualization Operating system level virtualization Full virtualization is a virtualization technology where a special virtual machine monitor (hypervisor) provides virtual machines with access to computer hardware. Advantages: Isolates the virtual machine from the main OS (host OS) and other virtual machines. Controls virtual machine resources, preventing an unstable VM from affecting the entire system. Full VM protability. VMs can be migrated to another architecture without any modifications. Disadvantages: Hardware emulation reduces performance. **Paravirtualization** VM OS must have a modified kernel. The VM OS sends all (processor, memory, devices) requests to the hypervisor using a specialized API. The hypervisor is responsible for processing and forwarding requests to the hardware **Operating system layer virtualization** Operating system level virtualization is a virtualization solution where the virtual machine monitor is installed in an existing operating system (Windows, Linux) and runs as a separate program. For example: VMware Microsoft virtual PC VirtualBOX **Hypervisor** A layer of software that works directly with the hardware and replaces the operating system, thereby allowing the computer hardware to run multiple operating systems in parallel. Functions performed by VMM: Provides and manages virtual hardware resources for VMs Controls VM access privilege modes to the CPU Isolates VMs from each other Monitors physical resources