'\"macro stdmacro .TH TASKCREATE 3P LOCAL .SH NAME taskcreate \- create a new task .Op c p a .SH C SYNOPSIS .B #include .P .br .B "tid_t taskcreate (char \(**name, void (\(**entry)(), void \(**arg," .br .ie n \{\ .B " int sched);" \} .el \{\ .B " int sched);" \} .Op .Op f .SH FORTRAN SYNOPSIS .B "integer *4 function taskcreate (name, entry, arg, sched)" .br .B "character\(**(\(**) name" .br .B "external entry" .br .B "integer*4 arg" .br .B "integer*4 sched" .br .Op .SH DESCRIPTION .I Taskcreate causes a new task to be created for the calling process/task. The new task is created via the .I sproc(2) system call, requesting that all attributes (e.g. open files, current directory, uid, etc.) be shared. .PP The new task differs from the calling task as described in .I sproc(2). .PP The new task will be invoked as follows: .RS 1i .B entry(arg) .br .B void \(**arg; .br .RE .PP The .I sched parameter is currently unused and should be set to 0. .PP No implicit synchronization is implied between tasks - they are free to run on any processor in any sequence. Synchronization must be provided by the application using locks and semaphores (see .IR usinit(3P) ). .PP Each created task has a task block allocated. The task blocks are linked together and pointed to by .I taskheader. The task block structure is defined in .I task.h. .PP .I Taskcreate will fail and no new task will be created if one or more of the following are true: .PP The .I sproc(2) system call fails. .TP 15 .SM \%[ENOMEM] The required memory for the task block or task name was not available. .SH "SEE ALSO" sproc(2), taskblock(3P), taskctl(3P), taskdestroy(3P). .SH DIAGNOSTICS Upon successful completion, .I taskcreate returns the task id of the new task. The task id is guaranteed to be the smallest available. Otherwise, a value of \-1 is returned to the calling task, and .I errno\^ is set to indicate the error.