Skip to contentSkip to conversation

thrd_create.3: Add entry for thrd_create function

PATCH In review Juan Manuel Torres Palma 2 participants 2 messages Sep 7, 2015 – Sep 8, 2015 1 message not in the archive Man-pages: manual pages for Linux -- Sections 2, 3, 4, 5, and 7

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 thrd_create.3: Add entry for thrd_create function

This patch adds a new entry for thrd_create function, belonging to ISO C11 threads.h API. More than a patch, I see it as a RFC so someone can tell me if I'm going in the right direction.

My patchset for C11 threads.h is still pending of revision on glibc, but I have already started working on documentation for man-pages.

Most of the work in this file is based in pthread_create.3, that was written by Michael Kerrisk. Please, let me know if I should mention you on the copyright header.

---
 man3/thrd_create.3 | 104 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 104 insertions(+)
 create mode 100644 man3/thrd_create.3
man3/thrd_create.3 new file +104 -0
new file mode 100644
index 0000000..1e8eb53
@@ -0,0 +1,104 @@
+.\" Copyright (c) 2015 Juan Manuel Torres Palma <[email protected]>
+.\"
+.\" %%%LICENSE_START(VERBATIM)
+.\" Permission is granted to make and distribute verbatim copies of this
+.\" manual provided the copyright notice and this permission notice are
+.\" preserved on all copies.
+.\"
+.\" Permission is granted to copy and distribute modified versions of this
+.\" manual under the conditions for verbatim copying, provided that the
+.\" entire resulting derived work is distributed under the terms of a
+.\" permission notice identical to this one.
+.\"
+.\" Since the Linux kernel and libraries are constantly changing, this
+.\" manual page may be incorrect or out-of-date.  The author(s) assume no
+.\" responsibility for errors or omissions, or for damages resulting from
+.\" the use of the information contained herein.  The author(s) may not
+.\" have taken the same level of care in the production of this manual,
+.\" which is licensed free of charge, as they might when working
+.\" professionally.
+.\"
+.\" Formatted or processed versions of this manual, if unaccompanied by
+.\" the source, must acknowledge the copyright and authors of this work.
+.\" %%%LICENSE_END
+.\"
+.TH THRD_CREATE 3 2015-07-23 "Linux" "Linux Programmer's Manual"
+.SH NAME
+thrd_create \- create a new thread
+.SH SYNOPSIS
+.nf
+.B #include <threads.h>
+
+.BI "int thrd_create(thrd_t *" thread ", thrd_start_t " func ", void *" arg );
+.fi
+.sp
+Compile and link with \fI\-lpthread\fP or \fI\-pthread\fP.
+.SH DESCRIPTION
+Create a new thread that executes
+.IR func ();
+being
+.IR arg
+the argument passed to
+.IR func ().
+
+The new thread could finish in any of the following ways:
+.IP * 2
+By calling
+.BR thrd_exit (3).
+.IP *
+By reaching a
+.I return
+statement. This is equivalent to calling
+.BR thrd_exit (3),
+returning the value specified in the
+.I return
+statement.
+.IP *
+Any of the threads in the process calls
+.BR exit (3),
+or the main thread performs a return from
+.IR main ().
+This causes the termination of all threads in the process.
+
+When called, a successful call to
+.BR thrd_create (),
+if successful, the ID of the new thread in the buffer pointed to by
+.IR thread ;
+this identifier is used to refer to the thread
+in subsequent calls to other thread functions.
+
+.SS Linux-specific details
+The
+.IR <threads.h>
+API is implemented on top of
+.IR <pthread.h>
+functions, so most of the documentation found for
+.IR <pthread.h>
+is applicable for
+.IR <threads.h>
+too.
+.SH RETURN VALUE
+.TP
+.B thrd_success
+Indicates that new thread has been created successfully.
+.TP
+.B thrd_nomem
+The new thread could not be spawned because there was not
+sufficient memory to allocate resources.
+.TP
+.B thrd_error
+Any other error occurred and the new thread could not be created.
+.SH ERRORS
+All the errors caused by
+.IR <threads.h>
+functions are notified via return values. Check
+.B RETURN VALUE
+section for more details.
+.SH CONFORMING TO
+ISO/IEC 9899:2011, C11.
+.SH SEE ALSO
+.ad l
+.nh
+.BR thrd_exit (3),
+.BR thrd_join (3),
+.BR thrd_current (3)
Signature · 6 lines
2.4.3

--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 1441665962-14853-1-git-send-email-j.m.torrespalma-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#2 lore raw

Hello Juan,

Quoted 3 lines · Juan Manuel Torres Palma

This patch adds a new entry for thrd_create function, belonging to ISO C11 threads.h API. More than a patch, I see it as a RFC so someone can tell me if I'm going in the right direction.

Okay. Thanks for working on this?

Quoted 3 lines

My patchset for C11 threads.h is still pending of revision on glibc, but I have already started working on documentation for man-pages.

Do you know have an idea when this patch series will make it into glibc? That info should appear in VERSIONS section in the page.

Quoted 3 lines

Most of the work in this file is based in pthread_create.3, that was written by Michael Kerrisk. Please, let me know if I should mention you on the copyright header.

Not sure yet. As me again later, when we see how the draft evolves.

Quoted 37 lines
---
 man3/thrd_create.3 | 104 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 104 insertions(+)
 create mode 100644 man3/thrd_create.3
man3/thrd_create.3 new file +25 -0
new file mode 100644
index 0000000..1e8eb53
@@ -0,0 +1,104 @@
+.\" Copyright (c) 2015 Juan Manuel Torres Palma <[email protected]>
+.\"
+.\" %%%LICENSE_START(VERBATIM)
+.\" Permission is granted to make and distribute verbatim copies of this
+.\" manual provided the copyright notice and this permission notice are
+.\" preserved on all copies.
+.\"
+.\" Permission is granted to copy and distribute modified versions of this
+.\" manual under the conditions for verbatim copying, provided that the
+.\" entire resulting derived work is distributed under the terms of a
+.\" permission notice identical to this one.
+.\"
+.\" Since the Linux kernel and libraries are constantly changing, this
+.\" manual page may be incorrect or out-of-date.  The author(s) assume no
+.\" responsibility for errors or omissions, or for damages resulting from
+.\" the use of the information contained herein.  The author(s) may not
+.\" have taken the same level of care in the production of this manual,
+.\" which is licensed free of charge, as they might when working
+.\" professionally.
+.\"
+.\" Formatted or processed versions of this manual, if unaccompanied by
+.\" the source, must acknowledge the copyright and authors of this work.
+.\" %%%LICENSE_END
+.\"
+.TH THRD_CREATE 3 2015-07-23 "Linux" "Linux Programmer's Manual"

man3/thrd_create.3 line 35

Quoted 10 lines
man3/thrd_create.3 new file +10 -0
+.SH NAME
+thrd_create \- create a new thread
+.SH SYNOPSIS
+.nf
+.B #include <threads.h>
+
+.BI "int thrd_create(thrd_t *" thread ", thrd_start_t " func ", void *" arg );
+.fi
+.sp
+Compile and link with \fI\-lpthread\fP or \fI\-pthread\fP.

Is compiling with -pthread not the preferred way? And so I'd drop mention of -lpthread.

man3/thrd_create.3 line 42

Quoted 7 lines
man3/thrd_create.3 new file +7 -0
+.SH DESCRIPTION
+Create a new thread that executes
+.IR func ();
+being
+.IR arg
+the argument passed to
+.IR func ().

The English here isn't quite right.

arg will be passed as the argument of func.

It would be helpful to let the reader know that thrd_start_t is

typedef int (* thrd_start_t)(void *) thrd_start_t.

Put that in the SYNOPSIS. I think.

man3/thrd_create.3 line 55

Quoted 8 lines
man3/thrd_create.3 new file +8 -0
+The new thread could finish in any of the following ways:
+.IP * 2
+By calling
+.BR thrd_exit (3).
+.IP *
+By reaching a
+.I return
+statement. 

Surely this should be: "by reaching a return statement *inside func*"

Quoted 6 lines

This is equivalent to calling
+.BR thrd_exit (3),

man3/thrd_create.3 new file +4 -0
+returning the value specified in the
+.I return
+statement.
+.IP *

man3/thrd_create.3 line 66

Quoted 10 lines
man3/thrd_create.3 new file +10 -0
+Any of the threads in the process calls
+.BR exit (3),
+or the main thread performs a return from
+.IR main ().
+This causes the termination of all threads in the process.
+
+When called, a successful call to
+.BR thrd_create (),
+if successful, the ID of the new thread in the buffer pointed to by
+.IR thread ;

Have a reread of the last sentence. Too many "successful".

Quoted 22 lines
man3/thrd_create.3 new file +22 -0
+this identifier is used to refer to the thread
+in subsequent calls to other thread functions.
+
+.SS Linux-specific details
+The
+.IR <threads.h>
+API is implemented on top of
+.IR <pthread.h>
+functions, so most of the documentation found for
+.IR <pthread.h>
+is applicable for
+.IR <threads.h>
+too.
+.SH RETURN VALUE
+.TP
+.B thrd_success
+Indicates that new thread has been created successfully.
+.TP
+.B thrd_nomem
+The new thread could not be spawned because there was not
+sufficient memory to allocate resources.
+.TP

man3/thrd_create.3 line 98

Quoted 10 lines
man3/thrd_create.3 new file +10 -0
+.B thrd_error
+Any other error occurred and the new thread could not be created.
+.SH ERRORS
+All the errors caused by
+.IR <threads.h>
+functions are notified via return values. Check
+.B RETURN VALUE
+section for more details.
+.SH CONFORMING TO
+ISO/IEC 9899:2011, C11.

This looks like two standards are listed. I'd prefer either just "C11" or else "C11 (ISO/IEC 9899:2011)".

Quoted 3 lines

+.SH SEE ALSO
+.ad l
+.nh

Ordering the following alphabetically:

Quoted 3 lines

+.BR thrd_exit (3),
+.BR thrd_join (3),
+.BR thrd_current (3)

Should we mention pthread_create(3) here?

Ultimately, I think a "threads(7)" (or "cthreads(7)") page (like pthreads(7)) may be desirable. All of the pages for the new C11 functions would link to that page, and vice versa.

Cheers,

Michael

Signature · 7 lines
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html