• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ semaphore_create函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中semaphore_create函数的典型用法代码示例。如果您正苦于以下问题:C++ semaphore_create函数的具体用法?C++ semaphore_create怎么用?C++ semaphore_create使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了semaphore_create函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: minisocket_initialize

/* Initializes the minisocket layer. */
void minisocket_initialize()
{
  int i;
  sock_array = (minisocket_t*)malloc(sizeof(struct minisocket)*NUM_SOCKETS);
  if (!sock_array) {
    return;
  }
  for (i = 0; i < NUM_SOCKETS; i++) {
    sock_array[i] = NULL;
  }
  client_lock = semaphore_create();
  if (!client_lock) {
    free(sock_array);
    return;
  }
  server_lock = semaphore_create();
  if (!server_lock) {
    free(sock_array);
    semaphore_destroy(client_lock);
    return;
  }
  semaphore_initialize(client_lock, 1);
  semaphore_initialize(server_lock, 1);
  network_get_my_address(my_addr);
  curr_client_idx = CLIENT_START;
  //printf("minisocket_initialize complete\n");
}
开发者ID:kentalabur,项目名称:egs,代码行数:28,代码来源:minisocket.c


示例2: vfs_init

void vfs_init(void)
{
    int i;

    vfs_table.sem = semaphore_create(1);
    openfile_table.sem = semaphore_create(1);

    KERNEL_ASSERT(vfs_table.sem != NULL && openfile_table.sem != NULL);

    /* Clear table of mounted filesystems. */
    for(i=0; i<CONFIG_MAX_FILESYSTEMS; i++) {
        vfs_table.filesystems[i].filesystem = NULL;
    }

    /* Clear table of open files. */
    for (i = 0; i < CONFIG_MAX_OPEN_FILES; i++) {
        openfile_table.files[i].filesystem = NULL;
    }

    vfs_op_sem = semaphore_create(1);
    vfs_unmount_sem = semaphore_create(0);

    vfs_ops = 0;
    vfs_usable = 1;

    kprintf("VFS: Max filesystems: %d, Max open files: %d\n",
            CONFIG_MAX_FILESYSTEMS, CONFIG_MAX_OPEN_FILES);
}
开发者ID:Rotte,项目名称:osm-k,代码行数:28,代码来源:vfs.c


示例3: blockdevice_create

BLOCKDEVICEP 
blockdevice_create(char *name, int blocksize, int numblocks)
{
	BLOCKDEVICEP devp ;
	int rc ;

	if (blocksize != REAL_BLOCK_LENGTH) {
		/*
		** For now we simplify things and just force
		** all blockdevices to have 1k block sizes.
		** We can fix this assumption up later.
		*/
		return NULL ;
	}

	if (strlen(name) >= BLOCK_DEV_MAX_NAME_LEN) {
		return NULL ;
	}

	devp = malloc(sizeof(BLOCKDEVICE)) ;

	if (NULL == devp) {
		return NULL ;
	}

	devp->name = malloc(strlen(name)+1) ;

	if (NULL == devp->name) {
		free(devp) ;
		return NULL ;
	}

	devp->sem = semaphore_create(1234, 0) ;
	devp->dirtysem = semaphore_create(1235, 0) ;

	/*if (! devp->sem) {
		free(devp) ;
		return NULL ;
	}*/

	strcpy(devp->name, name) ;
	devp->blocksize = blocksize ;
	devp->numblocks = numblocks ;
	devp->lastblockchecked = 0 ;

	rc = shmem_open() ;

	if (0 == rc) {
		semaphore_destroy(devp->sem, 1) ;
		free(devp->name) ;
		free(devp) ;
		return NULL ;
	}

	devp->bd = (struct SHMEM_BLOCK_OVERLAY *) shmem_get_memptr() ;

	initialize_block_dev_shmem(devp->bd, blocksize, numblocks, name) ;

	return devp ;
}
开发者ID:DEMONkill,项目名称:Nautilus,代码行数:60,代码来源:blockdevice.c


示例4: miniroute_initialize

/* Performs any initialization of the miniroute layer, if required. */
void
miniroute_initialize()
{
    network_get_my_address(hostaddr);
    discovery_alarm = -1;

    intrpt_buffer = queue_new();
    intrpt_sig = semaphore_create();
    discovery_mutex = semaphore_create();
    discovery_sig = semaphore_create();

    route_cache = miniroute_cache_new(65536, SIZE_OF_ROUTE_CACHE, MINIROUTE_CACHED_ROUTE_EXPIRE);
    disc_cache = miniroute_cache_new(65536, SIZE_OF_ROUTE_CACHE, MINIROUTE_CACHED_ROUTE_EXPIRE * 10);

    if (NULL == intrpt_buffer || NULL == intrpt_sig || NULL == route_cache
            || NULL == discovery_mutex || NULL == discovery_sig) {
        queue_free(intrpt_buffer);
        semaphore_destroy(intrpt_sig);
        semaphore_destroy(discovery_mutex);
        semaphore_destroy(discovery_sig);
        miniroute_cache_destroy(route_cache);
        return;
    }

    semaphore_initialize(intrpt_sig, 0);
    semaphore_initialize(discovery_mutex, 1);
    semaphore_initialize(discovery_sig, 0);

    network_get_my_address(hostaddr);

    minithread_fork(miniroute_control, NULL);
}
开发者ID:DolphinWilly,项目名称:PortOSnix,代码行数:33,代码来源:miniroute.c


示例5: minithread_system_initialize

/*
 * Initialization.
 *
 *      minithread_system_initialize:
 *       This procedure should be called from your C main procedure
 *       to turn a single threaded UNIX process into a multithreaded
 *       program.
 *
 *       Initialize any private data structures.
 *       Create the idle thread.
 *       Fork the thread which should call mainproc(mainarg)
 *       Start scheduling.
 *
 */
void
minithread_system_initialize(proc_t mainproc, arg_t mainarg) {
  minithread_t clean_up_thread = NULL;
  int a = 0;
  void* dummy_ptr = NULL;
  minithread_t tmp = NULL;
  tmp = NULL;
  dummy_ptr = (void*)&a;
  current_id = 0; // the next thread id to be assigned
  id_lock = semaphore_create();
  semaphore_initialize(id_lock,1); 
  runnable_q = multilevel_queue_new(4);
  blocked_q = queue_new();
  blocked_q_lock = semaphore_create();
  semaphore_initialize(blocked_q_lock,1);
  dead_q = queue_new();
  dead_q_lock = semaphore_create();
  semaphore_initialize(dead_q_lock,1);
  dead_sem = semaphore_create();
  semaphore_initialize(dead_sem,0);    
  runnable_q_lock = semaphore_create();
  semaphore_initialize(runnable_q_lock,1);
  clean_up_thread = minithread_create(clean_up, NULL);
  multilevel_queue_enqueue(runnable_q,
    clean_up_thread->priority,clean_up_thread);
  runnable_count++;
  minithread_clock_init(TIME_QUANTA, (interrupt_handler_t)clock_handler);
  init_alarm();
  current_thread = minithread_create(mainproc, mainarg);
  minithread_switch(&dummy_ptr, &(current_thread->stacktop));
  return;
}
开发者ID:kentalabur,项目名称:egs,代码行数:46,代码来源:minithread.c


示例6: minimsg_initialize

/* performs any required initialization of the minimsg layer. */
void minimsg_initialize() {
	int i;

	msgmutex = semaphore_create();
    semaphore_initialize(msgmutex, 1);

    bound_ports_free = semaphore_create();
    semaphore_initialize(bound_ports_free, BOUND_MAX_PORT_NUM - BOUND_MIN_PORT_NUM + 1);

    // Initialize ports array
	ports = (miniport_t*) malloc((BOUND_MAX_PORT_NUM + 1) * sizeof(miniport_t));

	if (ports == NULL) { // Fail if malloc() fails
      fprintf(stderr, "ERROR: minimsg_initialize() failed to malloc miniport_t array\n");
      return;
    }

    // Initialize each unbound port's data elements
    for (i = UNBOUND_MIN_PORT_NUM; i <= UNBOUND_MAX_PORT_NUM; i++) {
    	miniport_create_unbound(i);
    	ports[i]->u.unbound.incoming_data = queue_new();
    	ports[i]->u.unbound.datagrams_ready = semaphore_create();
    	semaphore_initialize(ports[i]->u.unbound.datagrams_ready, 0);
    }
}
开发者ID:jeherrera,项目名称:cs4411,代码行数:26,代码来源:minimsg.c


示例7: minisocket_create_socket

/*
 * Creates a socket 
 * The argument "port" is the port number of the created socket
 */
minisocket_t minisocket_create_socket(int port)
{
	minisocket_t newMinisocket;

	newMinisocket = (minisocket_t) malloc(sizeof(struct minisocket));

	if (newMinisocket == NULL)
		return NULL;

	//Initialize fields
	newMinisocket->port_number = port;
	newMinisocket->status = TCP_PORT_LISTENING;
	newMinisocket->seq_number = 0;
	newMinisocket->ack_number = 0;
	newMinisocket->data_buffer = NULL;
	newMinisocket->data_length = 0;
	newMinisocket->num_waiting_on_mutex = 0;
	newMinisocket->timeout = 100;

	newMinisocket->wait_for_ack_semaphore = semaphore_create();
	if (newMinisocket->wait_for_ack_semaphore == NULL)
	{
		free(newMinisocket);
		return NULL;
	}
	semaphore_initialize(newMinisocket->wait_for_ack_semaphore, 0);

	newMinisocket->mutex = semaphore_create();
	if (newMinisocket->mutex == NULL)
	{
		free(newMinisocket->wait_for_ack_semaphore);
		free(newMinisocket);
		return NULL;
	}
	semaphore_initialize(newMinisocket->mutex, 1);

	newMinisocket->packet_ready = semaphore_create();
	if (newMinisocket->packet_ready == NULL)
	{
		free(newMinisocket->mutex);
		free(newMinisocket->wait_for_ack_semaphore);
		free(newMinisocket);
		return NULL;
	}
	semaphore_initialize(newMinisocket->packet_ready, 0);

	newMinisocket->waiting_packets = queue_new();
	if (newMinisocket->waiting_packets == NULL)
	{
		free(newMinisocket->packet_ready);
		free(newMinisocket->mutex);
		free(newMinisocket->wait_for_ack_semaphore);
		free(newMinisocket);
		return NULL;
	}

	return newMinisocket;
}
开发者ID:authentic4269,项目名称:4411P2,代码行数:62,代码来源:minisocket.c


示例8: main

int
main(int argc, char *argv[]) {
  sem1 = semaphore_create();
  semaphore_initialize(sem1, 0);
  sem2 = semaphore_create();
  semaphore_initialize(sem2, 0);
  minithread_system_initialize(thread1, NULL);
  return -1;
}
开发者ID:kentalabur,项目名称:egs,代码行数:9,代码来源:test3.c


示例9: _retrieve_block

/* This needs to:
 * -get a block from the in-memory blocks if possible
 * -otherwise pull block from disk
 * -increment blocks' num_open counter
 * -we do NOT need to save the num_open update to disk, as it is reset after a 
 *  crash anyway.
 * 
 * Clients must ALWAYS check the return ID, in case a file was deleted.
 */
block_t _retrieve_block(int block_id)
{
	block_t block;
	minifile_t inode;
	int ret;
// todo - handle semaphores for inodes, destroy the in inode delete
	// First check if it's already in memory

	if (block_id < 0)
		return NULL;

	block = hashmap_get(retrieved_blocks, block_id);

	if (block != NULL && block->is_deleted == 0)
	{
		if ( block->block_type == BLOCK_TYPE_FILE
			|| block->block_type == BLOCK_TYPE_DIRECTORY)
		{
			block->num_open++;
			inode = (minifile_t) block;
			inode->u.data.mutex = semaphore_create();
			semaphore_initialize(inode->u.data.mutex, 1);
		}

		return block;
	}

	// Otherwise, get it from disk
	block = (block_t) malloc(sizeof(struct block));

	ret = _perform_full_disk_read(disk, block_id, (char*) block);

	// Setup the semaphore if it's an inode type

	// ONly check deleted for file/dir, as data blocks can have anything
	if (ret == 0 && !((block->block_type == BLOCK_TYPE_FILE || block->block_type == BLOCK_TYPE_DIRECTORY) && block->is_deleted == 1))
	{
		// Ensure num_open is set to just one, as we got it from disk (may have crashed with old data)
		hashmap_insert(retrieved_blocks, block_id, (void*) block);
		if ( block->block_type == BLOCK_TYPE_FILE
			|| block->block_type == BLOCK_TYPE_DIRECTORY)
		{
			inode = (minifile_t) block;
			inode->u.data.mutex = semaphore_create();
			semaphore_initialize(inode->u.data.mutex, 1);
			block->num_open = 1;
		}
		return block;
	}
	 else
	{
		return NULL;
	}
}
开发者ID:pb376,项目名称:cs4411-p6-submitted,代码行数:63,代码来源:block.c


示例10: main

void
main(void) {
  int maxcount = MAXCOUNT;
  
  size = head = tail = 0;
  empty = semaphore_create();
  semaphore_initialize(empty, 0);
  full = semaphore_create();
  semaphore_initialize(full, BUFFER_SIZE);

  minithread_system_initialize(producer, &maxcount);
}
开发者ID:DolphinWilly,项目名称:PortOSnix,代码行数:12,代码来源:buffer.c


示例11: command_move

void command_move(struct cmdStruct* commandsList, int socket)  {

  char fifoBuffer[__BUFFER_SIZE];
  int descr[2];
  int stdoutDescr = dup(STDOUT_FILENO);
  int stdinDescr = dup(STDIN_FILENO);
  int stderrDescr = dup(STDERR_FILENO);
  int size = 0;
  int status;
  int cStream = pipe(descr);
  int childPid;
  int semIdIn = semaphore_create(commandsList->words[1], 1);           /* Utworzenie semaforow do zabezpieczenia przed wielokrotną edycją */
  int semIdOut = semaphore_create(commandsList->words[2], 1);

  P(semIdIn, 0);
  P(semIdOut, 0);

  childPid = fork();

  if (childPid == 0)  {
    dup2(descr[1], 2);                                               /* przekierowanie stderr do FIFO_OUT */
    dup2(descr[1], 1);                                               /* przekierowanie stdout do FIFO_OUT */
    close(descr[0]);
    execvp("/bin/mv", commandsList->words);
                                                                     /* jezeli nie uda sie wykonac komendy, zglasza komunikat o bledzie i przywraca wejscia */
    dup2(stdinDescr, 0);                                              /* przywrocenie poprzednich wejsc */
    dup2(stdoutDescr, 1);
    dup2(stderrDescr, 2);
    info_remote_handler(socket, __COMMAND_EXEC_ERROR);
  } else  {
      dup2(descr[0], 0);                                             /* przekierowanie stdin na FIFO_IN */
      close(descr[1]);
      while (1)  {
        memset(fifoBuffer, 0, __BUFFER_SIZE);
        size = read(descr[0], fifoBuffer, sizeof(fifoBuffer));
        status = write(socket, fifoBuffer, size);
        if (size == 0)  {
          close(descr[0]);
          dup2(stdinDescr, 0);                                        /* przywrocenie poprzednich wejsc */
          dup2(stdoutDescr, 1);
          dup2(stderrDescr, 2);
          break;
        }
      }
      wait(0);
      V(semIdOut, 0);
      V(semIdIn, 0);
      if (semaphore_value_lookup(semIdIn, 0)) semaphore_remove(semIdIn);
      if (semaphore_value_lookup(semIdOut, 0)) semaphore_remove(semIdOut);
  }

}
开发者ID:AxuBlade,项目名称:TCPSrv,代码行数:52,代码来源:move.c


示例12: main

int
main(int argc, char * argv[]) {
  int maxcount = MAXCOUNT;
  
  size = head = tail = 0;
  empty = semaphore_create();
  semaphore_initialize(empty, 0);
  full = semaphore_create();
  semaphore_initialize(full, BUFFER_SIZE);

  minithread_system_initialize(producer, &maxcount);
  return -1;
}
开发者ID:Ekotlikoff,项目名称:Project2,代码行数:13,代码来源:buffer.c


示例13: main

int
main(void)
{
    pthread_t     pthread1, pthread2, pthread3;
    semaphore_t*   sem = g_sem;
    kern_return_t kr;

    setbuf(stdout, NULL);

    kr = semaphore_create(mach_task_self(), &sem[0], SYNC_POLICY_FIFO, 0);
    OUT_ON_MACH_ERROR("semaphore_create", kr);

    kr = semaphore_create(mach_task_self(), &sem[1], SYNC_POLICY_FIFO, 0);
    OUT_ON_MACH_ERROR("semaphore_create", kr);

    (void)pthread_create(&pthread1, (const pthread_attr_t *)0,
                         start_routine, (void *) 0);
    printf("created thread1=%lx\n", 0);

    (void)pthread_create(&pthread2, (const pthread_attr_t *)0,
                         start_routine, (void *) 1);
    printf("created thread2=%lx\n", 1);

    (void)pthread_create(&pthread3, (const pthread_attr_t *)0,
                         start_routine, (void *) 2);
    printf("created thread3=%lx\n", 2);

    // wait until all three threads are ready
    SEMAPHORE_WAIT(sem[1], 3);

//    printf("main: about to signal thread3\n");
//    semaphore_signal_thread(sem[0], pthread_mach_thread_np(pthread3));

    // wait for thread3 to sem_signal()
//    semaphore_wait(sem[1]);

    sleep(1);
    printf("main: about to signal all threads\n");
    semaphore_signal_all(sem[0]);

    // wait for thread1 and thread2 to sem_signal()
    SEMAPHORE_WAIT(sem[1], 3);

out:
    if (sem[0])
        semaphore_destroy(mach_task_self(), sem[0]);
    if (sem[1])
        semaphore_destroy(mach_task_self(), sem[1]);

    exit(kr);
}
开发者ID:010001111,项目名称:darling,代码行数:51,代码来源:mach_semaphore.c


示例14: block_device_init_driver

status_t block_device_init_driver (void)
{
  int32_t i ;
  char alpha_num[8], semaphore_name_buffer[64], * semaphore_prefix = "block_device_" ;
  char isr_semaphore_name[64] ;
  
  watch (status_t)
  {
    block_device_controls = kernel_malloc (sizeof (block_device_control_t) * 
        SOCLIB_BLOCK_DEVICES_NDEV, true) ;
    ensure (block_device_controls != NULL, DNA_OUT_OF_MEM) ;
    

    for (i = 0 ; i < SOCLIB_BLOCK_DEVICES_NDEV ; i++)
    {
      dna_itoa (i, alpha_num) ;
      dna_strcpy (semaphore_name_buffer, semaphore_prefix) ;
      dna_strcat (semaphore_name_buffer, alpha_num) ;
      dna_strcat (semaphore_name_buffer, "_sem") ;

      semaphore_create (semaphore_name_buffer, 1, 
          &block_device_controls[i] . semaphore_id) ;

      block_device_controls[i] . should_enable_irq = 
        (bool) SOCLIB_BLOCK_DEVICES[i] . should_enable_irq ;
      block_device_controls[i] . port = 
        (block_device_register_map_t) SOCLIB_BLOCK_DEVICES[i] . base_address ;

      cpu_read (UINT32, 
          & (block_device_controls[i] . port -> BLOCK_DEVICE_SIZE), 
          block_device_controls[i] . block_count) ;
      cpu_read (UINT32, 
          & (block_device_controls[i] . port -> BLOCK_DEVICE_BLOCK_SIZE), 
          block_device_controls[i] . block_size) ;

      if (block_device_controls[i] . should_enable_irq) {
        block_device_controls[i] . irq = SOCLIB_BLOCK_DEVICES[i] . irq ;
        interrupt_attach (0, SOCLIB_BLOCK_DEVICES[i] . irq, 0x0, 
            block_device_isr, false) ;
        dna_strcpy (isr_semaphore_name, semaphore_name_buffer) ;
        dna_strcat (isr_semaphore_name, "_isr") ;
        semaphore_create (isr_semaphore_name, 0, 
            &block_device_controls[i] . isr_semaphore_id) ;
      }

    }

    return DNA_OK ;
  }
}
开发者ID:marcoscunha,项目名称:reverse,代码行数:50,代码来源:block_device_init_driver.c


示例15: create_route_request

/* Create a route request struct - this stores information regarding the current
 * route discovery attempt.
 */
route_request_t create_route_request()
{
	route_request_t route_request = (route_request_t) malloc(sizeof(struct route_request));
	if (route_request == NULL)
		return NULL;

	route_request->threads_waiting = 0;
	route_request->initiator_sem = semaphore_create();
	route_request->waiting_sem = semaphore_create();
	semaphore_initialize(route_request->initiator_sem, 0);
	semaphore_initialize(route_request->waiting_sem, 0);
	route_request->interrupt_arg = NULL;

	return route_request;
}
开发者ID:pb376,项目名称:cs4411-p5,代码行数:18,代码来源:miniroute.c


示例16: sys_semaphore_create

s32 sys_semaphore_create(vm::ptr<u32> sem, vm::ptr<sys_semaphore_attribute_t> attr, s32 initial_val, s32 max_val)
{
	sys_semaphore.Warning("sys_semaphore_create(sem=*0x%x, attr=*0x%x, initial_val=%d, max_val=%d)", sem, attr, initial_val, max_val);

	if (!sem || !attr)
	{
		return CELL_EFAULT;
	}

	if (max_val <= 0 || initial_val > max_val || initial_val < 0)
	{
		sys_semaphore.Error("sys_semaphore_create(): invalid parameters (initial_val=%d, max_val=%d)", initial_val, max_val);
		return CELL_EINVAL;
	}

	const u32 protocol = attr->protocol;

	switch (protocol)
	{
	case SYS_SYNC_FIFO: break;
	case SYS_SYNC_PRIORITY: break;
	case SYS_SYNC_PRIORITY_INHERIT: break;
	default: sys_semaphore.Error("sys_semaphore_create(): unknown protocol (0x%x)", protocol); return CELL_EINVAL;
	}

	if (attr->pshared.data() != se32(0x200) || attr->ipc_key.data() || attr->flags.data())
	{
		sys_semaphore.Error("sys_semaphore_create(): unknown attributes (pshared=0x%x, ipc_key=0x%x, flags=0x%x)", attr->pshared, attr->ipc_key, attr->flags);
		return CELL_EINVAL;
	}

	*sem = semaphore_create(initial_val, max_val, protocol, attr->name_u64);

	return CELL_OK;
}
开发者ID:Bruceharper,项目名称:rpcs3,代码行数:35,代码来源:sys_semaphore.cpp


示例17: _dispatch_sema4_create_slow

void
_dispatch_sema4_create_slow(_dispatch_sema4_t *s4, int policy)
{
	semaphore_t tmp = MACH_PORT_NULL;

	_dispatch_fork_becomes_unsafe();

	// lazily allocate the semaphore port

	// Someday:
	// 1) Switch to a doubly-linked FIFO in user-space.
	// 2) User-space timers for the timeout.

#if DISPATCH_USE_OS_SEMAPHORE_CACHE
	if (policy == _DSEMA4_POLICY_FIFO) {
		tmp = (_dispatch_sema4_t)os_get_cached_semaphore();
		if (!os_atomic_cmpxchg(s4, MACH_PORT_NULL, tmp, relaxed)) {
			os_put_cached_semaphore((os_semaphore_t)tmp);
		}
		return;
	}
#endif

	kern_return_t kr = semaphore_create(mach_task_self(), &tmp, policy, 0);
	DISPATCH_SEMAPHORE_VERIFY_KR(kr);

	if (!os_atomic_cmpxchg(s4, MACH_PORT_NULL, tmp, relaxed)) {
		kr = semaphore_destroy(mach_task_self(), tmp);
		DISPATCH_SEMAPHORE_VERIFY_KR(kr);
	}
}
开发者ID:linux-on-ibm-z,项目名称:swift-corelibs-libdispatch,代码行数:31,代码来源:lock.c


示例18: create_data

void create_data(){
	struct semaphore* s=semaphore_create(M);
	set_bouncer(s);
	
	struct BB* bb=BB_create(A);
	set_ABB(bb);
	
	bb=BB_create(A);
	set_DrinkBB(bb);
	
	bb=BB_create(C);
	set_CBB(bb);
	// buy new cups
	int i;
	for(i=0; i<C; i++){
		struct Cup* c=malloc(sizeof(struct Cup));
		c->id=next_cupID;
		next_cupID++;
		printf(1, "buy new cup\n");
		BB_put(cbb, c);
	}
	
	bb=BB_create(C);
	set_DBB(bb);
}
开发者ID:RonBarabash,项目名称:OS132-Ass2,代码行数:25,代码来源:simulation.c


示例19: test4

int test4(void)
{
    thread_id tid;
    sem_id sid;
    status_t err;
    int res = 1;

    /* create new semaphore */
    sid = semaphore_create(NULL, 1, 0);
    if(sid == INVALID_SEMID)
        return 0;

    /* create thread */
    tid = sys_create_thread(thread_func, &sid, false, 0);
    if(tid == INVALID_THREADID)
        return 0;

    /* wait for created thread count up semaphore */
    err = semaphore_down_timeout(sid, 1, 1000);
    if(err != NO_ERROR)
        res = 0;

    /* delete semaphore */
    err = semaphore_delete(sid);
    if(err != NO_ERROR)
        res = 0;

    return res;
}
开发者ID:skarpenko,项目名称:phlox,代码行数:29,代码来源:test4.c


示例20: MACH_CHECK

Threading::Semaphore::Semaphore()
{
	// other platforms explicitly make a thread-private (unshared) semaphore
	// here. But it seems Mach doesn't support that.
	MACH_CHECK(semaphore_create(mach_task_self(), (semaphore_t *)&m_sema, SYNC_POLICY_FIFO, 0));
	__atomic_store_n(&m_counter, 0, __ATOMIC_SEQ_CST);
}
开发者ID:Aced14,项目名称:pcsx2,代码行数:7,代码来源:DarwinSemaphore.cpp



注:本文中的semaphore_create函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ semaphore_destroy函数代码示例发布时间:2022-05-30
下一篇:
C++ semaphore_V函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap