Answer:
-32 to +31
Explanation:
6 bit 2s complement representation will be of the form b1b2b3b4b5b6 where each bit is either 0 or 1.
The largest positive number that can be represented using this scheme is 011111
Translating this to decimal this is 1*2^4 + 1^2^3 + 1^2^2 + 1^2^1 + 1^2^0
=16 + 8 + 4 + 2 + 1 =31
The smallest negative number that can be represented using this scheme is 100000
Translating this to decimal = -1 * 2^5 = -32
So the range of decimal values that can be represented is -32 to +31.
Answer:
B. False
Explanation:
When a value is placed in a memory location, the previous value in that location is not moved to the next available location in memory. Rather than that happening, the previous value is totally discarded or removed from memory. In other words, the previous value is over-written. To prevent this from happening, the programmer has to explicitly or expressly move the previous value to another location in memory.
A sixteen bit microprocessor chip used in early IBM PCs. The Intel 8088 was a version with an eight-bit externaldata bus.
The Intel 8086 was based on the design of the Intel 8080 <span>and </span>Intel 8085 (it was source compatible with the 8080)with a similar register set, but was expanded to 16 bits. The Bus Interface Unit fed the instruction stream to theExecution Unit through a 6 byte prefetch queue, so fetch and execution were concurrent - a primitive form ofpipelining (8086 instructions varied from 1 to 4 bytes).
It featured four 16-bit general registers, which could also be accessed as eight 8-bit registers, and four 16-bit indexregisters (including the stack pointer). The data registers were often used implicitly by instructions, complicatingregister allocation for temporary values. It featured 64K 8-bit I/O (or 32K 16 bit) ports and fixed vectored interrupts.There were also four segment registers that could be set from index registers.
The segment registers allowed the CPU to access 1 meg of memory in an odd way. Rather than just supplyingmissing bytes, as most segmented processors, the 8086 actually shifted the segment registers left 4 bits and addedit to the address. As a result, segments overlapped, and it was possible to have two pointers with the same valuepoint to two different memory locations, or two pointers with different values pointing to the same location. Mostpeople consider this a brain damaged design.
Although this was largely acceptable for assembly language, where control of the segments was complete (it couldeven be useful then), in higher level languages it caused constant confusion (e.g. near/far pointers). Even worse, thismade expanding the address space to more than 1 meg difficult. A later version, the Intel 80386, expanded thedesign to 32 bits, and "fixed" the segmentation, but required extra modes (suppressing the new features) forcompatibility, and retains the awkward architecture. In fact, with the right assembler, code written for the 8008 canstill be run on the most <span>recent </span>Intel 486.
The Intel 80386 added new op codes in a kludgy fashion similar to the Zilog Z80 and Zilog Z280. The Intel 486added full pipelines, and clock doubling (like <span>the </span>Zilog Z280).
So why did IBM chose the 8086 series when most of the alternatives were so much better? Apparently IBM's own engineers wanted to use the Motorola 68000, and it was used later in the forgotten IBM Instruments 9000 Laboratory Computer, but IBM already had rights to manufacture the 8086, in exchange for giving Intel the rights to its bubble memory<span> designs.</span> Apparently IBM was using 8086s in the IBM Displaywriter word processor.
Other factors were the 8-bit Intel 8088 version, which could use existing Intel 8085-type components, and allowed the computer to be based on a modified 8085 design. 68000 components were not widely available, though it could useMotorola 6800 components to an <span>extent.
</span>
Hope this helps
Answer:
A mutex is used here.
A mutex is a locking mechanism set before using a shared resource and is released after using the shared resource. When the lock is set, only one task accesses the mutex.
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<pthread.h>
#include<unistd.h>
pthread_t tid[2];
int flag=0;
int a = 0;
pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
void *thread_a(void *arg)
{
pthread_mutex_lock(&lock);
a += 2;
pthread_mutex_unlock(&lock);
flag = 1;
return NULL;
}
void *thread_b(void *arg)
{
int b = 0;
if(flag){
b++;
}
b += 3;
pthread_mutex_lock(&lock);
a -= b;
pthread_mutex_unlock(&lock);
return NULL;
}
int main()
{
while(1) {
pthread_create(&tid[0],NULL,thread_a,NULL);
pthread_create(&tid[1],NULL,thread_b,NULL);
sleep(1);
}
pthread_exit(NULL);
return 0;
}