Search:

Type: Posts; User: Salem

Page 1 of 20 1 2 3 4

Search: Search took 0.16 seconds.

  1. Replies
    7
    Views
    111

    Well I see your difficulty, because you have...

    Well I see your difficulty, because you have this.

    > p[1] = (void*)&(pjob_data->socket_ids[pjob_data->open_cnncts]);

    Maybe implement point 4 in #2
  2. Replies
    7
    Views
    111

    pjob_data->socket_ids[pjob_data->open_cnncts] =...

    pjob_data->socket_ids[pjob_data->open_cnncts] = temp;
    p[0] = (void*)pjob_data;
    p[1] = (void*)&(pjob_data->socket_ids[pjob_data->open_cnncts]);
    printf("SOCKETFD %d\n",...
  3. Replies
    7
    Views
    111

    1. Sloppy formatting at line 104. 2. At line...

    1. Sloppy formatting at line 104.

    2. At line 111, you exit the thread whilst still holding the mutex.

    3. You're still writing outside the mutex.


    ...
  4. Replies
    7
    Views
    111

    There are multiple issues. 1. You call...

    There are multiple issues.

    1. You call delete_socket() outside the scope of the mutex.


    if(n == 0){
    delete_socket(new_sock_fd, pjob_data);
    pthread_exit(NULL);...
  5. Why not remove the variable declaration within...

    Why not remove the variable declaration within main altogether and go with


    t_dserver *get_display_server()
    {
    static t_dserver dserver = { 0 }; // saves a bzero call
    return &dserver;
    }
  6. Thread: Mutex

    by Salem
    Replies
    7
    Views
    102

    1. If you think that you can get away with not...

    1. If you think that you can get away with not locking your data structure at all for reading, then you are mistaken.
    The lack of locks on read just means any write lock will immediately succeed and...
  7. Thread: Mutex

    by Salem
    Replies
    7
    Views
    102

    > but if the reconfiguring-thread is working,...

    > but if the reconfiguring-thread is working, both arrays must not read the array....
    So what's to stop the reconfigure thread from making changes half-way though a read?

    As in


    // "If the...
  8. Thread: Mutex

    by Salem
    Replies
    7
    Views
    102

    Not in any atomically useful manner. ...

    Not in any atomically useful manner.

    pthread_mutex_lock(3): lock/unlock mutex - Linux man page
    You could build something out of pthread_mutex_trylock, but that would inevitably mess up in the...
  9. Replies
    9
    Views
    255

    Yes, you are very much mistaken as to how shell...

    Yes, you are very much mistaken as to how shell variables work.
    For one thing, environment variables only propagate from parent to child, not the other way round. So once a script actually exits,...
  10. Replies
    6
    Views
    125

    > Compiled ok, but did not work? The extra...

    > Compiled ok, but did not work? The extra brackets are needed, not sure I understand why...
    Because pointer arithmetic.

    > struct dev_state *ds = (struct dev_state *)(data+sizeof(struct...
  11. Replies
    8
    Views
    169

    Start by fixing all your warnings. $ gcc...

    Start by fixing all your warnings.


    $ gcc -Wall -Wextra foo.c -pthread
    foo.c: In function ‘job_read’:
    foo.c:29:11: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits]...
  12. Replies
    6
    Views
    125

    So use a different cast. struct dev_state *ds ...

    So use a different cast.
    struct dev_state *ds = (struct dev_state *)(data+sizeof(struct jcp_header));
  13. Replies
    9
    Views
    255

    You're waiting for a bunch of external processes...

    You're waiting for a bunch of external processes that take seconds to complete.

    Are you REALLY sure that the 0.1% time difference between you clearing the memory and the program exiting (and the...
  14. Replies
    1
    Views
    100

    Like so. char buff[BUFSIZ]; while (...

    Like so.


    char buff[BUFSIZ];
    while ( fgets(buff,BUFSIZ,fptr) != NULL ) {
    if ( strstr(buff,FIND) != NULL ) {
    printf("Found %s", buff);
    }
    }
  15. Replies
    9
    Views
    255

    I'm wondering what line 41 is doing > ...

    I'm wondering what line 41 is doing
    > for(int i=0;i<inst-1 && b;i++)

    And the subsequent value of j when you eventually get to
    > execlp(scmd, scmd,...
  16. Thread: Coding error?

    by Salem
    Replies
    11
    Views
    167

    Beware of ; on the ends of statements like for...

    Beware of ; on the ends of statements like
    for (int index = 0; index < 20; index++);
    and
    else if (random_integer >= high);
  17. Try Windows Sysinternals - Windows Sysinternals |...

    Try Windows Sysinternals - Windows Sysinternals | Microsoft Docs
  18. Replies
    3
    Views
    165

    Header files are always greyed out in code...

    Header files are always greyed out in code blocks.

    What happens when you try to build (press the yellow cog-wheel icon)?
  19. Copy paste gets you every time :D

    Copy paste gets you every time :D
  20. Replies
    7
    Views
    254

    So it's a maths question then. > Here's how it...

    So it's a maths question then.

    > Here's how it works:
    > - We can give the computer a number x(1 to 10^9).the computer replies with x^2%P.
    > - We need to tell the value of P.

    So you start with...
  21. Replies
    7
    Views
    254

    > I know We need to apply fermat's little theorem...

    > I know We need to apply fermat's little theorem on it. but due to the large range am getting lost most of the times.
    So practice with smaller numbers to begin with.

    The thing about mathematical...
  22. Replies
    7
    Views
    331

    > operation(1726956429,'

    > operation(1726956429,'<',5) call 4
    > rstarted 1198, rstopped 1199, nstarted 1199, nstopped 1228
    > num << val -571969120, 1709982365
    Why does less-than appear as left-shift?
  23. Replies
    10
    Views
    428

    It's not that difficult to do in C. It's just...

    It's not that difficult to do in C.

    It's just that it's a hell of a lot easier to do in sed.
  24. Thread: UDS with C

    by Salem
    Replies
    6
    Views
    323

    Unless you really know what you're doing, use...

    Unless you really know what you're doing, use libraries wherever you can.

    I don't know if you can completely trash a car if you touch the wrong thing with your fumbling around.
  25. > hours = (s >= 0 && s < 24) ? s : 0 ; Try...

    > hours = (s >= 0 && s < 24) ? s : 0 ;
    Try setting seconds.
    Try with 60 seconds.
Results 1 to 25 of 500
Page 1 of 20 1 2 3 4