logo

Crowdly

SISTEMAS OPERATIVOS

Looking for SISTEMAS OPERATIVOS test answers and solutions? Browse our comprehensive collection of verified answers for SISTEMAS OPERATIVOS at moodle.uam.es.

Get instant access to accurate answers and detailed explanations for your course questions. Our community-driven platform helps students succeed!

Se desea crear un proceso hijo que mande una señal al padre tras

realizar su trabajo. El padre debe establecer un manejador vacío

para la señal y esperar a la señal en el código principal. ¿Qué

secuencia de llamadas al sistema se debe realizar (en el orden

especificado) para que no haya ninguna condición de carrera?

0%
0%
100%
0%
View this question
¿Quién mantiene la información sobre las señales pendientes y bloqueadas asociadas a un proceso?
0%
0%
100%
0%
View this question

Dado el siguiente código C, ¿en qué parte del código se realiza realmente la gestión de la señal?

#include <signal.h>

#include <stdio.h>

#include <stdlib.h>

#include <sys/types.h>

#include <unistd.h>

static volatile sig_atomic_t got_signal = 0;

/* Handler function for the signal SIGINT. */

void handler(int sig) { got_signal = 1; }

int main(void) {

struct sigaction act;

act.sa_handler = handler;

sigemptyset(&(act.sa_mask));

act.sa_flags = 0;

if (sigaction(SIGINT, &act, NULL) < 0) {

perror("sigaction");

exit(EXIT_FAILURE);

}

while (1) {

printf("Waiting Ctrl+C (PID = %d)\n", getpid());

if (got_signal) {

got_signal = 0;

printf("Signal received.\n");

}

sleep(9999);

}

}

0%
100%
0%
0%
View this question

¿Cómo se hace referencia a una señal en C?

0%
0%
100%
0%
View this question

La función

sem_unlink se puede usar:

100%
0%
0%
0%
View this question

Dado el siguiente código C, ¿cuántos semáforos serían necesarios para garantizar que se impriman siempre los números en orden?

#include <fcntl.h>

#include <semaphore.h>

#include <stdio.h>

#include <stdlib.h>

#include <sys/stat.h>

#include <sys/wait.h>

#include <unistd.h>

int main(void) {

pid_t pid;

pid = fork();

if (pid < 0) {

perror("fork");

exit(EXIT_FAILURE);

}

if (pid == 0) {

printf("1\n");

printf("3\n");

} else {

printf("2\n");

printf("4\n");

wait(NULL);

exit(EXIT_SUCCESS);

}

}

0%
0%
100%
0%
View this question

Dado el siguiente código C, ¿cuándo se imprimirá el mensaje "Signal number 2 received"?

#include <signal.h>

#include <stdio.h>

#include <stdlib.h>

#include <sys/types.h>

#include <unistd.h>

/* Handler function for the signal SIGINT. */

void handler(int sig) {

printf("Signal number %d received\n", sig);

fflush(stdout);

}

int main(void) {

struct sigaction act;

act.sa_handler = handler;

sigemptyset(&(act.sa_mask));

act.sa_flags = 0;

if (sigaction(SIGINT, &act, NULL) < 0) {

perror("sigaction");

exit(EXIT_FAILURE);

}

while (1) {

printf("Waiting Ctrl+C (PID = %d)\n", getpid());

sleep(9999);

}

}

100%
0%
0%
0%
View this question

Dado el siguiente código C, ¿qué sucede cuando el proceso recibe la señal SIGINT?

#include <fcntl.h>

#include <semaphore.h>

#include <signal.h>

#include <stdio.h>

#include <stdlib.h>

#include <sys/stat.h>

#include <sys/wait.h>

#include <unistd.h>

#define SEM_NAME "/example_sem"

int main(void) {

sem_t *sem = NULL;

struct sigaction act;

if ((sem = sem_open(SEM_NAME, O_CREAT | O_EXCL, S_IRUSR | S_IWUSR, 0)) ==

SEM_FAILED) {

perror("sem_open");

exit(EXIT_FAILURE);

}

sigemptyset(&(act.sa_mask));

act.sa_flags = 0;

/* The handler for SIGINT is set. */

act.sa_handler = SIG_IGN;

if (sigaction(SIGINT, &act, NULL) < 0) {

perror("sigaction");

exit(EXIT_FAILURE);

}

printf("Starting wait (PID=%d)\n", getpid());

sem_wait(sem);

printf("Finishing wait\n");

sem_unlink(SEM_NAME);

}

0%
0%
100%
0%
View this question

Se crea un semáforo binario en un programa en C con la siguiente inicialización:

sem_t *sem = sem_open("/mi_semaforo", O_CREAT, 0644, 0);

Dado este semáforo, ¿qué ocurre si un proceso ejecuta sem_wait(&sem); inmediatamente después de la inicialización?

0%
0%
100%
0%
View this question

¿A qué proceso y que tipo de señal envía la función alarm después de que se cumpla el tiempo especificado por parámetro?

View this question

Want instant access to all verified answers on moodle.uam.es?

Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!