Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7023553
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:43:32+00:00 2026-05-27T23:43:32+00:00

I am writing a multithreaded C program and I have an error. I have

  • 0

I am writing a multithreaded C program and I have an error.
I have a 2D array array worker_table declared globally as:

int **worker_table;

And allocated in main as follows:

worker_table        = (int**) calloc(number_of_workers*2,(sizeof(int)));

This is the worker function:

    void *Worker(void *worker_id)
    {

my_id = (int)worker_id;    //id of the worker
printf("Line 231\n");
printf("My id is %d\n",my_id);
my_customer = worker_table[my_id][1];//line 233
printf("Line 234\n");
int my id;

The error happens before line 234, I think what is wrong is on line 233, but I can’t figure out what it is.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T23:43:33+00:00Added an answer on May 27, 2026 at 11:43 pm

    Your allocation is wrong. It should be like this:

    worker_table = calloc(number_of_workers,(sizeof(int*)));
    for(int i = 0; i < 2; ++i)
    {
       worker_table[i] = calloc(2, sizeof(int));
    }
    

    And the freeing procedure should be:

    for(int i = 0; i < 2; ++i)
    {
        free(worker_table[i]);
    }
    free(worker_table);
    

    I suggest that you should read a good book on C

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing a multithreaded program in java. I have written something like this
I have a client program as follows and I need to make it multithreaded
I'm writing a multithreaded program, which would crash when a particular exception was thrown.
Let's say I have a multithreaded C++ program that handles requests in the form
I am writing a multithreaded program where I want to handle a possible Ctrl-C
I'm writing a Java program involving a multithreaded worker pool of Process es. Each
I was writing a program to illustrate the effects of cache contention in multithreaded
I am writing a multithreaded parser. Parser class is as follows. public class Parser
In a multithreaded C++ program, I have the equivalent of this running in one
I am writing a multithreaded program in which i am getting exception java.lang.IllegalThreadStateException .

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.