Anda di halaman 1dari 2

UNIVERSITY OF ENGINEERING & TECHNOLOGY Kohat Campus

Department of Electrical Engineering Microprocessor Based System Design Spring 2013


Date: -21-02-2013 Due Date: -xx-xx-2013

Assignment # 01 (Solution)

Q#1:What we mean by 2s complement? How it works? Give examples. Solution:Two's complement is a mathematical operation on binary numbers, as well as a binary signed number representation based on this operation. The two's complement of an N-bit number is defined as taking the ones' complement and then adding one, since the sum of a number and its ones' complement is all 1 bits. Adding 15 with -5.

11111 111 (carry) 0000 1111 (15) + 1111 1011 (5) ================== 0000 1010 (10)

Q#2:-

What we mean by internal & external fragmentation & what are different methods/ algorithms to solve these issues? Solution:Internal Fragmentation:Due to the rules governing memory allocation, more computer memory is sometimes allocated than is needed. For example, memory can only be provided to programs in chunks divisible by 4, 8 or 16, and as a result if a program requests perhaps 23 bytes, it will actually get a chunk of 24. When this happens, the excess memory goes to waste. In this scenario, the unusable memory is contained within an allocated region, and is thus termed internal fragmentation. External Fragmentation:External fragmentation arises when free memory is separated into small blocks and is interspersed by allocated memory. It is a weakness of certain storage allocation algorithms, when they fail to order memory used by programs efficiently. The result is that, although free storage is available, it is effectively unusable because it is divided into pieces that are too small individually to satisfy the demands of the application. The term "external" refers to the fact that the unusable storage is outside the allocated regions.

Algorithms:There are three algorithms that are used to solve above issues. These are first fit, best fit & worst fit.

Q#3:What we mean by thrashing & what are different methods/ algorithms to solve these issues? Solution:In computer science, thrashing occurs when a computer's virtual memory subsystem is in a constant state of paging, rapidly exchanging data in memory for data on disk, to the exclusion of most application-level processing. This causes the performance of the computer to degrade or collapse. The situation may continue indefinitely until the underlying cause is addressed. To resolve thrashing due to excessive paging, a user can do any of the following:

Increase the amount of RAM in the computer (generally the best long-term solution). Decrease the number of programs being run on the computer. Replace programs that are memory-heavy with equivalents that use less memory. Improve spatial locality by replacing loops.

Anda mungkin juga menyukai