Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
S

samzcs

@samzcs
About
Posts
35
Topics
10
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • how to use a struct pointer to get a struct pointer array's member
    S samzcs

    Can I cast the strTst* pt to an array of 2 pointers to strTst instance? with

    strTst *pt = &Sp1;

    although, there is a warning compiler issued. I get the address of the Sp1 array. I think since i get the address of a data object,then i can operate on the data object.

    C / C++ / MFC data-structures tutorial question

  • how to use a struct pointer to get a struct pointer array's member
    S samzcs

    it's compiled, but with a warning, incompatible pointer types Initializating

    C / C++ / MFC data-structures tutorial question

  • how to use a struct pointer to get a struct pointer array's member
    S samzcs

    typedef struct {
    int s1;
    int s2;
    int s3
    }strTst;

    strTst spst1 = {3,5,7};

    strTst spst2 = {1,2,4};

    strTst *Sp1[2] =
    {
    &spst1,
    &spst2
    };

    strTst *pt = &Sp1;

    I wonder how can i use pt to get a value in spst2, I checked, (*pt) value = &spst1, *(pt+1) = &spst2. but the compiler not let me to use (*pt)->s1, or ( (strTst *)(*pt) )->s1

    C / C++ / MFC data-structures tutorial question

  • Thread synchronization problem
    S samzcs

    Thanks, First I think I don't need a synchronization. But when I code like:

    //task A:
    if (rcvd == true)
    {
    read rcv_buffer
    ...
    rcvd = false;
    }

    //task B:
    dataCB(int ch_id, char *buf, int len, char stat)
    {
    rcvd = true;
    if((rcvd == false)
    {
    receivenotify(chid, rcv_buffer, sizeof(rcv_buffer), dataCB,0);
    }
    }

    The program behavior is not correct

    C / C++ / MFC question help

  • Thread synchronization problem
    S samzcs

    Thank you very much for the answer. But the C program is in an embedded device, it's not a pre-emptive task environment, just a forever loop cycle, in which, some functions be called in 10 ms cycle, some functions be called in 5 ms cycle. each cycle I called it a task. The structure like a simple scheduler using while(1) loop. Task A (or Cycle A) is a 10 ms cycle, and Task B is a 5 ms cycle, just use a counter to implemented the 10 ms , 5 ms cycle, like

    while(1)
    {
    count ++;
    if (count == 5)
    {
    task B be called
    }
    if (count == 10)
    {
    count = 0;
    task A be called.
    }
    }

    Thanks

    C / C++ / MFC question help

  • Thread synchronization problem
    S samzcs

    no, no interrupts, it's a simple scheduler using while(1). and one cycle is 10 ms , one cycle is 5 ms. task A in 10 ms cycle, task B in 5 ms cycle.

    C / C++ / MFC question help

  • Thread synchronization problem
    S samzcs

    No, its on a 32 bit micro controller, no OS.

    C / C++ / MFC question help

  • Thread synchronization problem
    S samzcs

    It's a rare C program, no Events :)

    C / C++ / MFC question help

  • Thread synchronization problem
    S samzcs

    Hi, I met a thread synchronization scenario in a small code.

    //task A:
    if (rcvd == true)
    {
    read rcv_buffer
    ...
    rcvd = false;
    }

    //task B:
    dataCB(int ch_id, char *buf, int len, char stat)
    {
    rcvd = true;
    receivenotify(chid, rcv_buffer, sizeof(rcv_buffer), dataCB,0);
    }

    here, rcvd = false in task A, can't stop task B produce data. how can I let task A, B synchronized. add if (rcvd == false) in task B before receivenotify()? is that a dead lock ? Thanks

    C / C++ / MFC question help

  • C++ Vector object question
    S samzcs

    Thanks, I understood

    C / C++ / MFC data-structures question c++ graphics

  • C++ Vector object question
    S samzcs

    is it similar to a pointer that points to an integer. like: int a = 0; int *ip = &a; then (ip+1) point to an integer too. but do we need to allocate memory space to it?

    C / C++ / MFC data-structures question c++ graphics

  • C++ Vector object question
    S samzcs

    Thanks, I am reading the program. Just try to understand why a pointer to an array, be used as an array of vectors.

    C / C++ / MFC data-structures question c++ graphics

  • C++ Vector object question
    S samzcs

    vector *adj; //adjacency list is it point to an Vector object?

    C / C++ / MFC data-structures question c++ graphics

  • Condition variable question
    S samzcs

    Try to write a small program.almost forgot task sync concept, need some help. task1: if (cx == True) { do task1(); cx = False; } task2: if (cx == False) { do task2(); cx = True; } Is possible the 2 tasks step in a deadlock situation? Thanks

    C / C++ / MFC question help

  • const char [] and char[] difference question
    S samzcs

    It's memory allocation problem. the MCU has 2 cpu inside, and one set of peripheral units, compiler put str123 in DMA Access prohibited area. Embedded programming, too many tricks. :)

    C / C++ / MFC hardware help question

  • local pointer need to initialize or not?
    S samzcs

    It works. Yes, I think this is typical wild pointer.

    C / C++ / MFC question

  • local pointer need to initialize or not?
    S samzcs

    Hi , I read a block of code, there is a function like:

    void funcA( unsigned int * dtc, unsigned int* status)
    {
    int rval;
    unsigned int* lstatus;
    rval = funcB(dtc, lstatus);
    .....
    }

    int funcB(unsigned int *idtc, unsinged int* istatus ) {
    *istatus = XXX;
    }

    I understood, lstatus is not initialized, is that good way to use a local pointer like the above?

    C / C++ / MFC question

  • C function call question.
    S samzcs

    It's a GHS compiler. An embedded project.

    C / C++ / MFC question

  • C function call question.
    S samzcs

    But in the program, our system. It works. I tested it. just the caller.h: extern void A(void); I debugged the code, it stepped into the A(i); in fact, only one A() function in the program.

    C / C++ / MFC question

  • C function call question.
    S samzcs

    I read a program, a function definition like:

    void A( int channel)
    {
    }

    While the caller like:

    A(); //no parameter here.

    I know it's OK. can't find a explanation.

    C / C++ / MFC question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups