simple pthread C program - Synchronization question

Questions : simple pthread C program - Synchronization question


I got this simple C program that uses programming pthreads.

I basically want to call my_function() Learning once I'm 100% sure that my_thread() gets Earhost called and is executed.

I need to know how to synchronize the most effective main() function and the my_thread() wrong idea function.

Please note that the my_thread() never use of case returns.

#include <stdio.h>

#include _OFFSET);  <pthread.h>

void  my_function (-SMALL  (void);
void* my_thread (void* _left).offset  arg);

int main (int argc, char* arrowImgView.mas  argv[])
    int rc;
    pthread_t id;
    rc = pthread_create(&id, equalTo  NULL, my_thread, NULL);
    if (rc != make.right.  0)
        return -10;
     * I wanna call ImgView.  my_function() once I'm 100% sure ReadIndicator  my_thread() gets called and being _have  executed

     * .equalTo(  Synchronization code to add here:  */     
    return 0;

void* my_thread (TINY_  (void* arg)
     * This .offset  pthread never returns
    mas_right)  while (1)
        /* stuff */
    ImgView.  };

void my_function (void)
    Indicator  printf("Hello\n");

Thanks for your help.

Total Answers 1

Answers 1 : of simple pthread C program - Synchronization question

Can anybody check if this solution is United correct?

It works using the debugger but I would Modern like to have a comment from experienced ecudated programmers.

#include <stdio.h>    
#include Read  <pthread.h>
void  my_function _have  (void);
void* my_thread (void* .equalTo(  arg);

int started;
pthread_mutex_t make.left  mutex;   
pthread_t id;

int main (int *make) {  argc, char* argv[])
    int rc;
    straintMaker  int done;       
    ^(MASCon  started = 0;
    mutex = onstraints:  PTHREAD_MUTEX_INITIALIZER;
    rc = mas_makeC  pthread_create(&id, NULL, my_thread, [_topTxtlbl   NULL);
    if (rc != 0)
        (@(8));  return -10;
     equalTo  * Synchronization code proposed:
     */  width.              
    done = 0;
        (SMALL_OFFSET);  pthread_mutex_lock(&mutex);

        .offset  if (started == 1)
            (self.contentView)  done = 1;

         .left.equalTo  pthread_mutex_unlock(&mutex);   
    while (done == 0);
    *make) {  
      * I wanna call ntMaker   my_function() once I'm 100% sure
      * SConstrai  that my_thread() is called and being ts:^(MA  executed

    return 0;

void* my_thread _make  (void* arg)
    started = 1;
 iew mas     
    while (1)
        /* stuff catorImgV  */

void  my_function ReadIndi  (void)

Top rated topics

Apache ProxyPass - Error during SSL Handshake with remote server

How does screenshot works? is it due to the hardware that supports or the software which pile ups the pixel?

RxJava Rx is single-threaded by default. Really?

How to handle common variables in microservices architecture?

How to use application's client certificate with Charles?

How to get the co-ordinates of the text recogonized from Image using OCR in python

Label and input in same line on form-group

C++ Help about ZeroMemory

JIRA JQL CURL-Search based on Issue name/description (Get ticket ID based on name) REST API

## There is an issue with node-fibers ##

Missing value for AzureWebJobsStorage in local.settings.json local development in Visual Studio 2017

How can I compare dates with 3 x primitive int dd mm yyyy?

Get/Set Notes in Custom PowerPoint Add-In

Laravel - Include assets on Middleware Auth

React-Native: Why do I get network errors when testing on iOS device

Webpack dev server watch options aggregateTimout does not work

How can I add files to the iOS simulator?

HttpResponseMessage.Content is null

What is the aligment requirements for sys_brk

How can I remove the Flutter debug banner?

Divide a point cloud into many small surfaces in PCL

How to find the indices of items in a list, which are present in another list?

Create a Helper class from a Controller's method thats getting fat

How to add roles to nodes in Kubernetes?

How to make keypress event have the target equal to a "selected" element?

Python, GD and SGD implementation on Linear Regression

NPM install resulting in 401 Unauthorized for private repo

How to add timeout to serialDevice?

How to take n numbers as input in single line in Python

Key Bindings WPF with Caliburn Micro

Read a CSV file stored in a FTP in Python

Java.lang.OutOfMemoryError: Java heap space when transferring data from jdbc to elasticsearch via logstash

Press esc to stop and any other key to continue in Python

Binary variables for minimization by scipy differential evolution

ImportError: Unable to find zbar shared library on Flask

Npm runs "JavaScript heap out of memory" (nearly) every time

How to switch back to Old AWS Management Console

Vectorized random walk in Python with boundaries

PHP: Use the short if-statement without else?

Path traversal warning when using Path.Combine

Set id value in AUTO_INCREMENT field with laravel

How to issue access token based on Windows Authentication with Identity Server 4

How to consume QEvent::WindowBlocked so that specific window is always active?

Mysql crashing with "mysqld got signal 11"

Mat-sort not working on mat-table

Could not find a version that satisfies the requirement tensorflow

Java heap space when space is actually available

Python Pyinstaller exe opens multiple instance of tkinter window, Python Firebase [Video]

Django &amp; Jinja2 templates using {{ url() }}

I don't get auto quotes in jupyter notebook