⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 thread4.c

📁 gdb-6.8 Linux下的调试程序 最新版本
💻 C
字号:
/* Compiler options:#notarget: cris*-*-elf#cc: additional_flags=-pthread#output: abb ok\n   Testing a pthread corner case.  Output will change with glibc   releases.  */#include <stddef.h>#include <stdio.h>#include <unistd.h>#include <pthread.h>#include <stdlib.h>static void *process (void *arg){  int i;  if (pthread_setcancelstate (PTHREAD_CANCEL_ENABLE, NULL) != 0)    abort ();  write (2, "a", 1);  for (i = 0; i < 10; i++)    {      sched_yield ();      pthread_testcancel ();      write (2, "b", 1);    }  return NULL;}intmain (void){  int retcode;  pthread_t th_a;  void *retval;  retcode = pthread_create (&th_a, NULL, process, NULL);  sched_yield ();  sched_yield ();  sched_yield ();  sched_yield ();  retcode = pthread_cancel (th_a);  retcode = pthread_join (th_a, &retval);  if (retcode != 0)    abort ();  fprintf (stderr, " ok\n");  return 0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -