Jump to content

Recommended Posts

Posted

Boas TOu a resolver uns exames de universidade... podem me ajudar numas questões?

1- Explique o seguinte extracto de código, identifique os eventuasi problemas e indique, caso entenda relevente, as adquadas alternativas...

---------------------

int main() {

  pthread_t thread[N];

  int id[N];

  for ( int i; i<N; i++)  {

      id =i;

      pthread_create(&thread, NULL,&server, &id );

  }

  return 0;

}

e

exercicio 2:

Explique o seguiinte código e identifique, justificandom eventuais secções críticas do mesmo.

#include<stdio.h>

#include<stdlib.h>

#include<unistd.h>

int main (int argc, char *argv[]){

  pid_t childpid = 0;

  int i, n;

  if (argc !=2) {

      fprintf(stderr, "%s syntax error...\n", argv[+]);

      return 1;

  }

  n= atoi(argv[1];

  for /i =1; i < n; i++)

      if (chlidpid = fork());

        break;

  fsprintf(stderr, "%d %ld %ld %ld \n", i (long) getpid(), (long) getpid(), (long) childpid());

return 0;

}

Agradecia vossa ajuda!!!

Posted

Podemos e certamente ajudaremos, mas aí só vi "copy paste" do enunciado.

Não vi onde tinhas dúvidas.

Quais são as tuas dúvidas nos dois exercícios?

É que se esperas que alguém chegue e despeje as respostas, ninguém o vai fazer.

Abraço

"Great coders aren't born. They're compiled and released"

"Expert coders do not need a keyboard. They just throw magnets at the RAM

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.