GradePack

    • Home
    • Blog
Skip to content
bg
bg
bg
bg

Author Archives: Anonymous

Why can preemptive scheduling lead to race conditions?

Why can preemptive scheduling lead to race conditions?

Read Details

Considering the code: #include #include #include pthread_…

Considering the code: #include #include #include pthread_mutex_t lock1; pthread_mutex_t lock2; void* thread1(void* arg) { pthread_mutex_lock(&lock1); printf(“Thread 1 acquired lock1\n”); sleep(1); pthread_mutex_lock(&lock2); printf(“Thread 1 acquired lock2\n”); pthread_mutex_unlock(&lock2); pthread_mutex_unlock(&lock1); return NULL; } void* thread2(void* arg) { pthread_mutex_lock(&lock2); printf(“Thread 2 acquired lock2\n”); sleep(1); pthread_mutex_lock(&lock1); printf(“Thread 2 acquired lock1\n”); pthread_mutex_unlock(&lock1); pthread_mutex_unlock(&lock2); return NULL; } int main() { pthread_t t1, t2; pthread_mutex_init(&lock1, NULL); pthread_mutex_init(&lock2, NULL); pthread_create(&t1, NULL, thread1, NULL); pthread_create(&t2, NULL, thread2, NULL); pthread_join(t1, NULL); pthread_join(t2, NULL); pthread_mutex_destroy(&lock1); pthread_mutex_destroy(&lock2); return 0; } What is the MOST likely output?

Read Details

A system is considered to be in a safe state if:

A system is considered to be in a safe state if:

Read Details

In a client-server socket model, which sequence correctly re…

In a client-server socket model, which sequence correctly represents the communication flow?

Read Details

A process has: Arrival Time = 1 ms First CPU Allocation = 4…

A process has: Arrival Time = 1 ms First CPU Allocation = 4 ms Completion Time = 15 ms Burst Time = 9 ms What is the waiting time?

Read Details

What is the value of semaphore S after this sequence? Initia…

What is the value of semaphore S after this sequence? Initial Value: S = 3 Execution: wait(S); wait(S); signal(S);

Read Details

A system satisfies bounded waiting but allows two processes…

A system satisfies bounded waiting but allows two processes simultaneously inside the critical section. Which requirement of solution to critical-section problem fails? 

Read Details

On a system with two CPUs, Process P1 disables interrupts on…

On a system with two CPUs, Process P1 disables interrupts on CPU1 and enters the critical section. What is the main problem?

Read Details

Considering the code:  #include #include #include #includ…

Considering the code:  #include #include #include #include sem_t empty; sem_t full; int item = 0; void* producer(void* arg) { sem_wait(&empty); item = 100; printf(“Producer produced item\n”); sem_post(&full); return NULL; } void* consumer(void* arg) { sem_wait(&full); printf(“Consumer consumed item = %d\n”, item); sem_post(&empty); return NULL; } int main() { pthread_t p, c; sem_init(&empty, 0, 1); sem_init(&full, 0, 0); pthread_create(&c, NULL, consumer, NULL); sleep(1); pthread_create(&p, NULL, producer, NULL); pthread_join(p, NULL); pthread_join(c, NULL); return 0; } Which statement is CORRECT?

Read Details

A system uses a semaphore queue to control access to a share…

A system uses a semaphore queue to control access to a shared printer. Process P1 requests access first and is placed in the waiting queue. However, every time the printer becomes available, newly arriving higher-priority processes (P2, P3, P4, …) are always selected before P1. As a result, P1 never gets access to the printer even though the system continues running normally. What synchronization issue is demonstrated?

Read Details

Posts pagination

Newer posts 1 2 3 4 … 85,225 Older posts

GradePack

  • Privacy Policy
  • Terms of Service
Top