User Tools

Site Tools


cs:posix:threads_example1
Return to Home page

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
cs:posix:threads_example1 [2019/11/22 18:52]
zioskenz
cs:posix:threads_example1 [2019/11/22 18:54] (current)
zioskenz
Line 82: Line 82:
 </​file>​ </​file>​
  
-**Comments:​**+**Comments:​**\\
 This example shows how to pass a structure to threads (in ''​pthread_create()''​). Each thread **must** work on its own data (i.e., its own element of the vector of structures),​ otherwise it is possible that the data it reads is modified by the ''​main()''​ in the meanwhile, and it contains the data for the following thread generated by ''​pthread_create()''​. This example shows how to pass a structure to threads (in ''​pthread_create()''​). Each thread **must** work on its own data (i.e., its own element of the vector of structures),​ otherwise it is possible that the data it reads is modified by the ''​main()''​ in the meanwhile, and it contains the data for the following thread generated by ''​pthread_create()''​.
  
Line 91: Line 91:
 Global variable can be accessed by all the thread. If you want to modify them, you need to do it in a non concurrent way. To this purpose //​semaphores//​ can be employed. Global variable can be accessed by all the thread. If you want to modify them, you need to do it in a non concurrent way. To this purpose //​semaphores//​ can be employed.
  
-**Compilation:​**+**Compilation:​**\\
 To compile the program type the following command: To compile the program type the following command:
 <code bash> <code bash>

If you found any error, or if you want to partecipate to the editing of this wiki, please contact: admin [at] skenz.it

You can reuse, distribute or modify the content of this page, but you must cite in any document (or webpage) this url: https://www.skenz.it/cs/posix/threads_example1?rev=1574445271&do=diff
/web/htdocs/www.skenz.it/home/data/pages/cs/posix/threads_example1.txt ยท Last modified: 2019/11/22 18:54 by zioskenz

Privacy Policy