Ejemplo n.º 1
0
int main(){

     /* init materiels */
    if(!boot()){
        fprintf(stderr, "FATAL: L'initialisation du matériels a échoué.\n");
        exit(EXIT_FAILURE);
    }

    printf("passage du boot\n");

    /* controle d'acces au tampon */
    sem_init(&mutex, 1);
    /* nb de places libres */
    sem_init(&vide, N);
    /* nb de places occupees */
    sem_init(&plein, 0);
    
    if( ! create_ctx(STACK_SIZE, producteur, NULL, 2)){
        fprintf(stderr, "ERROR: echec creation de contexte.\nt");
        exit(EXIT_FAILURE);
    }
    
    if( ! create_ctx(STACK_SIZE, consommateur, NULL, 3)){
        fprintf(stderr, "ERROR: ehec creation de contexte.\n");
        exit(EXIT_FAILURE);
    }

    irq_enable();

    while(1);

    fprintf(stderr, "ERROR: Retour au main.\n");
    exit(EXIT_FAILURE);
}
Ejemplo n.º 2
0
int main (int argc, char *argv[]) {
  create_ctx(16384, &f_ping, NULL);
  create_ctx(16384, &f_pong, NULL);
  create_ctx(16384, &f_pang, NULL);
  start_schedule();
  exit(EXIT_SUCCESS);
}
Ejemplo n.º 3
0
int main (void){
	create_ctx(16384, f_ping, NULL);
	create_ctx(16384, f_pong, NULL);
	yield() ;

	exit(EXIT_SUCCESS);
}
Ejemplo n.º 4
0
int main(int argc, char *argv[])
{
  create_ctx(16384,&f_ping, NULL);
  create_ctx(16384,&f_pong, NULL);
  create_ctx(16384,&f_pang, NULL);
  yield();

  exit(EXIT_SUCCESS);
}
Ejemplo n.º 5
0
Archivo: 06.c Proyecto: edgd1er/seatp1
int main(int argc, char *argv[])
{
  sem_init(&gsem,1);
  create_ctx(16384, f_ping, NULL);
  create_ctx(16384, f_pong, NULL);
  start_sched();
  for(;;);
  exit(EXIT_SUCCESS);
}
Ejemplo n.º 6
0
int main(int argc, char *argv[])
{
  create_ctx(16384, f_ping, NULL);
  create_ctx(16384, f_pong, NULL);
  start_sched();
  // le sleep sert a attendre 1 seconde, dans le cas contraire, l'application fini trop vite pour pouvoir réaliser le ping pong
  sleep(1000);
  printf("\ntest retour au main\n");
  exit(EXIT_SUCCESS);
}
Ejemplo n.º 7
0
int main(void){
  sem_init(&mutex, 1);                /* controle d'acces au tampon */
  sem_init(&vide, N);                 /* nb de places libres */
  sem_init(&plein, 0);                /* nb de places occupees */
  create_ctx(16384, producteur, NULL);
  create_ctx(16384, consommateur, NULL);
  start_sched();
  printf("\ntest retour au main\n");

return EXIT_SUCCESS;
}
Ejemplo n.º 8
0
int main(int argc, char *argv[])
{
	int retour=0;	
	init();
	/*Spawn du module Traduction*/
	retour+=create_ctx(16384, lancerTraducteur, NULL);
	/*Spawn du module Actionneur*/
	retour+=create_ctx(16384, lancerActionneur, NULL);
	if(retour==0)
	{
		start_sched();
		exit(EXIT_SUCCESS);
	}
	exit(EXIT_FAILURE);
}
Ejemplo n.º 9
0
void*          webSocketTest()
{

  noPollConn     * conn;
  noPollCtx      * ctx;

  /* init context */
  ctx = create_ctx ();

  /* create connection */
  conn = nopoll_conn_new (ctx, "echo.websocket.org", "80", NULL, NULL, NULL, NULL);
  if (! nopoll_conn_is_ok (conn)) {
    printf ("ERROR: Expected to find proper client connection status, but found error..\n");
    return nopoll_false;
  } /* end if */

  /* check test */
  if (! test_sending_and_check_echo (conn, "Test 26", "This is a test"))
    return nopoll_false;

  /* close the connection */
  nopoll_conn_close (conn);

  /* release context */
  nopoll_ctx_unref (ctx);

  return nopoll_true;
}
Ejemplo n.º 10
0
static void
create_context(GLXContext ctx)
{
	gl_context_t *glc;
	unsigned int ctx_num;

	GH_verbose(GH_MSG_DEBUG, "created ctx %p\n",ctx);

	pthread_mutex_lock(&ctx_mutex);
	ctx_num=ctx_counter++;
	if (!ctx_num) {
		pthread_key_create(&ctx_current, NULL);
		pthread_setspecific(ctx_current, NULL);
		/* query the function pointers for the standard functions
		 * which might be often called ... */
		GH_GET_PTR_GL(glXSwapBuffers);
		GH_GET_PTR_GL(glXMakeCurrent);
		GH_GET_PTR_GL(glXMakeContextCurrent);
		GH_GET_PTR_GL(glXMakeCurrentReadSGI);
		GH_GET_PTR_GL(glFlush);
		GH_GET_PTR_GL(glFinish);
	}
	pthread_mutex_unlock(&ctx_mutex);
	
	glc=create_ctx(ctx, ctx_num);
	if (glc) {
		read_config(glc);
		/* add to our list */
		add_ctx(glc);
	} else {
		GH_verbose(GH_MSG_ERROR, "out of memory\n");
	}

}
Ejemplo n.º 11
0
Archivo: main.c Proyecto: DherJ/Master1
int main(int argc, char *argv[]){
	if(create_ctx(16384, f_ping, NULL) != 0)
		printf("Creation ctx ping OK\n");
	else printf("Creation ctx ping FAIL\n");

	if(create_ctx(16384, f_pong, NULL) != 0)
		printf("Creation ctx pong OK\n");
	else printf("Creation ctx pong FAIL\n");

	if(create_ctx(16384, f_pang, NULL) != 0)
		printf("Creation ctx pang OK\n");
	else printf("Creation ctx pang FAIL\n");

	yield();

	printf("Execution finish with success :)\n");
	return (0);
}
Ejemplo n.º 12
0
// à ne pas confondre avec l'initialisatio du matériel.
// à faire en cas de reset
void disk_sched_init(){
	disk_running = 0;
	disk_purge_queue(disk_queue);
	if(disk_ctx)
		sched_remove_ctx(disk_ctx);
	disk_ctx = create_ctx(65535000, disk_check_queue, NULL);
	ctx_set_name(disk_ctx, "disk_ctx");
	disk_state = DS_IDLE;
	IRQVECTOR[HDA_IRQ] = disk_sched_irq_handler;
	disk_running = DISK_MODE_SCHEDULED;
}
Ejemplo n.º 13
0
Archivo: main.c Proyecto: DherJ/Master1
int main(int argc, char *argv[]){ 
	sem_init(&mutex, "mutex", 1);
	sem_init(&vide, "vide", NBSEM);
	sem_init(&plein, "plein", 0);
	
	mutex.sem_cpt=1;
	vide.sem_cpt=100;
	plein.sem_cpt=0;
	mutex.sem_name="mutex";
	vide.sem_name="vide";
	plein.sem_name="plein";
	
	puts("Creation du contexte producteur ...");
	create_ctx(16384, producteur, NULL);
	puts("Creation du contexte consommateur ...");
	create_ctx(16384, consommateur, NULL);
	yield();
	printf("Fin du programme ...\n");

	exit(EXIT_SUCCESS);
}
Ejemplo n.º 14
0
int main(int argc, char *argv[])
{
  /*create the context for all the fonctions*/
  /*create_ctx(16384, f_ping, NULL);
    create_ctx(16384, f_pong, NULL);*/
  create_ctx(16384, producteur, NULL);
  create_ctx(16384, consommateur, NULL);

  /*initialise the semaphore*/
  mutex = malloc(sizeof(struct sem_s));
  sem_init(mutex, 1);
  fullSem = malloc(sizeof(struct sem_s));
  sem_init(fullSem, 0);
  emptySem = malloc(sizeof(struct sem_s));
  sem_init(emptySem, 1);

  /*start the schedule*/
  start_sched();
  printf("je suis revenu dans le main\n");
  exit(EXIT_SUCCESS);
}
Ejemplo n.º 15
0
//------------------------------------------------------------------------
int
notmain ( void )
{
  hw_init();
  music_init();

  /* hw_init(); */
  /* led_init(); */
  /* switch_init(); */

  /* play_music(); */
  create_ctx(processus_A, NULL, 128);
  create_ctx(processus_A, NULL, 128);

  create_ctx(play_music, NULL, 2048);

  create_ctx(processus_B, NULL, 128);
  create_ctx(processus_B, NULL, 128);

  start_sched();

  return(0);
}
Ejemplo n.º 16
0
Archivo: file.c Proyecto: xsoameix/wz
} END_TEST

START_TEST(test_decode_chars) {
  // It should decode ascii
  char ascii[] = "\x01\x23";
  wzkey key = {.bytes = (uint8_t *) "\x89\xab\xcd\xef", .len = 4};
  wzfile file = {.key = &key};
  wzstr buffer;
  buffer.bytes = (uint8_t *) ascii;
  buffer.len = strlen(ascii);
  ck_assert_int_eq(wz_decode_chars(&buffer, 1, file.key), 0);
  ck_assert_int_eq(memcmp(buffer.bytes, "\x22\x23", 2), 0);
  ck_assert(buffer.len == 2 && memused() == 0);

  // It should decode utf16le
  char utf16le[] = "\x45\x67"; // decode => \x66\x66  utf8 => \xe6\x99\xa6
  buffer.bytes = (uint8_t *) utf16le;
  buffer.len = strlen(utf16le);
  ck_assert_int_eq(wz_decode_chars(&buffer, 0, file.key), 0);
  ck_assert_int_eq(memcmp(buffer.bytes, "\xe6\x99\xa6", 3), 0);
  ck_assert(buffer.len == 3 && memused() == 3 + 1);
  wz_free_chars(&buffer);
  ck_assert(memused() == 0);

  // It should not decode if key == NULL
  wzstr copy = buffer;
  ck_assert_int_eq(wz_decode_chars(&buffer, 1, NULL), 0);
  ck_assert(buffer.bytes == copy.bytes);
  ck_assert(buffer.len == copy.len);

  // It should not decode if string key is too short
  file.key->bytes = (uint8_t *) "\xcd";
  file.key->len = 1;
  ck_assert_int_eq(wz_decode_chars(&buffer, 1, file.key), 1);
  ck_assert(buffer.bytes == copy.bytes);
  ck_assert(buffer.len == copy.len);
} END_TEST

START_TEST(test_read_chars) {
  // It should be ok
  char normal[] =
    "\xfe""\x01\x23"
    "\x80""\x02\x00\x00\x00""\x45\x67"
    "\x01""\x89\xab"
    "\x7f""\x03\x00\x00\x00""\xcd\xef\x01\x23\x45\x67";
  wzfile file;
  create_file(&file, normal, sizeof(normal) - 1);
  wzstr buffer;
  ck_assert_int_eq(wz_read_chars(&buffer, file.key, &file), 0);
  ck_assert_int_eq(memcmp(buffer.bytes, "\x01\x23", 2), 0);
  ck_assert(buffer.len == 2 && memused() == 2 + 1);
  wz_free_chars(&buffer);
  ck_assert_int_eq(wz_read_chars(&buffer, file.key, &file), 0);
  ck_assert_int_eq(memcmp(buffer.bytes, "\x45\x67", 2), 0);
  ck_assert(buffer.len == 2 && memused() == 2 + 1);
  wz_free_chars(&buffer);
  ck_assert_int_eq(wz_read_chars(&buffer, file.key, &file), 0);
  ck_assert_int_eq(memcmp(buffer.bytes, "\x89\xab", 2), 0);
  ck_assert(buffer.len == 2 && memused() == 2 + 1);
  wz_free_chars(&buffer);
  ck_assert_int_eq(wz_read_chars(&buffer, file.key, &file), 0);
  char * expected = "\xcd\xef\x01\x23\x45\x67";
  ck_assert_int_eq(memcmp(buffer.bytes, expected, 6), 0);
  ck_assert(buffer.len == 6 && memused() == 6 + 1);
  wz_free_chars(&buffer);
  delete_file(&file);

  // It should decode if string key is set
  create_file(&file, normal, sizeof(normal) - 1);
  wzctx ctx;
  create_ctx(&ctx);
  file.key = &ctx.keys[0];
  file.key->bytes = (uint8_t *) "\x01\x23\x45\x67\x89\xab";
  file.key->len = 6;
  ck_assert_int_eq(wz_read_chars(&buffer, file.key, &file), 0);
  ck_assert_int_eq(memcmp(buffer.bytes, "\xaa\xab", 2), 0);
  ck_assert(buffer.len == 2 && memused() == 2 + 1);
  wz_free_chars(&buffer);
  ck_assert_int_eq(wz_read_chars(&buffer, file.key, &file), 0);
  ck_assert_int_eq(memcmp(buffer.bytes, "\xee\xef", 2), 0);
  ck_assert(buffer.len == 2 && memused() == 2 + 1);
  wz_free_chars(&buffer);
  ck_assert_int_eq(wz_read_chars(&buffer, file.key, &file), 0);
  ck_assert_int_eq(memcmp(buffer.bytes, "\xe2\x88\xa2", 2), 0);
  ck_assert(buffer.len == 3 && memused() == 3 + 1);
  wz_free_chars(&buffer);
  ck_assert_int_eq(wz_read_chars(&buffer, file.key, &file), 0);
  expected = "\xe6\x99\xa6\xee\xbb\xaf\xe6\x99\xa0";
  ck_assert_int_eq(memcmp(buffer.bytes, expected, 9), 0);
  ck_assert(buffer.len == 9 && memused() == 9 + 1);
  wz_free_chars(&buffer);
  delete_ctx(&ctx);
  delete_file(&file);
} END_TEST

START_TEST(test_free_chars) {
  // It should be ok
  char normal[] = "\xfe\x01\x23";
  wzfile file;
  create_file(&file, normal, sizeof(normal) - 1);
  wzstr buffer;
  ck_assert_int_eq(wz_read_chars(&buffer, file.key, &file), 0);
  ck_assert(memused() == 2 + 1);
  wz_free_chars(&buffer);
  ck_assert(memused() == 0);
  delete_file(&file);
} END_TEST

START_TEST(test_rotl32) {
  // It should be ok
  ck_assert(wz_rotl32(0xf2345678, 3) == 0x91a2b3c7);
} END_TEST

void
wz_encode_addr(wzaddr * addr, wzfile * file) {
  uint32_t key = 0x581c3f6d;
  uint32_t decoded = ~(addr->pos - file->head.start);
  decoded = decoded * file->ver.hash - key;
  decoded = wz_rotl32(decoded, decoded & 0x1f);
  addr->val = decoded ^ (addr->val - file->head.start * 2);
}