User Profile

Collapse

Profile Sidebar

Collapse
jorba101
jorba101
Last Activity: Apr 16 '10, 01:42 PM
Joined: Jun 2 '08
Location: Igualada (Barcelona)
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • jorba101
    started a topic Looking for a macro equivalent to strlen()
    in C

    Looking for a macro equivalent to strlen()

    Is there any way of getting the length of a const char[] at compile time using macros?
    See more | Go to post

  • jorba101
    replied to Preemptive vs non-preemtive schemes
    in C
    Very interesting comment.

    Some remarks or observations from my experience:



    I agree that a preemptive system is less responsive to your custom ISRs, since they need to compete with the ones under control of the scheduler. Though, I also must say that the ISR's I write for one or other system do not change much: they are as short as possible, and leave the processing to background tasks, regardless if they...
    See more | Go to post

    Leave a comment:


  • jorba101
    replied to Preemptive vs non-preemtive schemes
    in C
    I think it's a basic one.

    If you do the same program, non-preemptive fashioned for an 8-bit OSless environment it won't change much from target to target, or even not change at all from a point of view of design.

    If you move the same application to a preemptive/multitasking scheme, it will be totally different.
    See more | Go to post

    Leave a comment:


  • jorba101
    replied to Preemptive vs non-preemtive schemes
    in C
    Not building an OS. Just wondering the parameters to be taken into account when choosing one scheme or the other.
    See more | Go to post

    Leave a comment:


  • jorba101
    started a topic Preemptive vs non-preemtive schemes
    in C

    Preemptive vs non-preemtive schemes

    I see two main big groups in embedded development:

    -Preemptive scheme, with several processes and/or threads running on the same system

    -Non-preemptive scheme, with interrupts

    I've read in some documentation that "preemptive scheme, in general, is more efficient". But such systems imply running constantly a scheduler. From Michael Barr's website I've learnt about the so-called "schedulabl e-bound",...
    See more | Go to post

  • jorba101
    started a topic Communication by means of a variable between threads
    in C

    Communication by means of a variable between threads

    In a UNIX-like environment, I'm wondering following:

    Given a certain variable, whose values is modified from a thread and read from another thread, should it be mutex-protected? Or perhaps the question depends on the concrete implementation on the OS / platform?

    I mean, the variable is always modified from the same thread, and read from the same (different) thread.
    See more | Go to post

  • jorba101
    replied to *NIX sockets question
    in C
    Well, you weren't that paranoid. I found out documentation on my OS literally states: "A given socket can be read or written by only one task at a time".

    So my will of having separate threads reading and writting is not possible. I'll have to think of something else.

    The reason for my question was to take as much advantadge as possible of the OS services: If something is already solved by the OS there is no...
    See more | Go to post

    Leave a comment:


  • jorba101
    started a topic Knowing if a file descriptor is open
    in C

    Knowing if a file descriptor is open

    Is there any way, using fcntl() to know whether a filedescriptor is open or closed (*NIX environment)
    See more | Go to post

  • jorba101
    replied to *NIX sockets question
    in C
    I'm using read(), write() and close(), which are syscalls. I don't know if in the background they're using socket library functions in my case. Are they?



    I'm just defending my point as I see it. My concern is producing quality code, and for discussing something and getting at the top of an issue I have to follow some reasoning line. I can't tell my management "I'm not doing it like this because some guru suggested...
    See more | Go to post

    Leave a comment:


  • jorba101
    replied to *NIX sockets question
    in C
    I'm aware of the problems of not mutexing things and so on and so forth, but what I'm worried here is about the specific issue:

    "Is it possible to work on the same file descriptor (for a socket, if that's relevant) from several threads at the same time?"

    If not, why not? How can I overcome this?

    My problem is that I have to implement bidirectional communication, without no end being a master....
    See more | Go to post

    Leave a comment:


  • jorba101
    replied to *NIX sockets question
    in C
    Aw... that was painful to read.

    Seriously, there is no way I can use it from a separate thread? Currently I'm passing the fd number as argument of a new thread. It works. But don't know if me and my app will end up in developer's hell for that.

    What about dup()? Would it help here?...
    See more | Go to post

    Leave a comment:


  • jorba101
    started a topic *NIX sockets question
    in C

    *NIX sockets question

    I've started with socket programming and follow question arose:

    If, in the server, I get a client/socket connection with function:

    Code:
    client_sockfd = accept( server_sockfd, (struct sockaddr *) &client_address, &client_len );
    Then, is it a problem if I access later on this client_sockfd from two separate threads? Can I close() it from any of them?

    I'm thinking of creating a thread to...
    See more | Go to post

  • jorba101
    replied to read() and write() behavior in *NIX
    in C
    Who'll remember my task is waiting for a semaphore? The OS?
    See more | Go to post

    Leave a comment:


  • jorba101
    started a topic read() and write() behavior in *NIX
    in C

    read() and write() behavior in *NIX

    When the file descriptor on which read() and write() apply is set up in such a way so that these syscalls block (for instance, until no data is available to read() from a serial port), I wonder following:

    What's the processor doing with this process while waiting, in general, in a *NIX? Is it busy-waiting, or sleeping?
    See more | Go to post

  • jorba101
    replied to gmtime and localtime functions from time.h
    in C
    By the way,

    Thanks for your comment:



    It was a critical issue I wouldn't have been aware myself. Now I'll use localtime_r() which my system implements....
    See more | Go to post

    Leave a comment:


  • jorba101
    replied to gmtime and localtime functions from time.h
    in C
    Thanks again Banfa.

    I've changed now my main reference for C language from "http://www.acm.uiuc.ed u/webmonkeys/book/c_guide/" to "http://www.cplusplus.c om/reference/", as I see it is more complete
    See more | Go to post

    Leave a comment:


  • jorba101
    started a topic gmtime and localtime functions from time.h
    in C

    gmtime and localtime functions from time.h

    Following prototypes apply for localtime and gmtime:

    Code:
    struct tm *localtime(const time_t *timer);
    struct tm *gmtime(const time_t *timer);
    I wonder, should I understand that localtime and gmtime do allocate a "struct tm" element, and so I must do a free() on them after using the value?

    If they do not allocate it, where does its memory come from?
    See more | Go to post

  • jorba101
    replied to Endianism
    in C
    Thanks for the explanations.

    Anyway, going to simple things.

    Code:
    int t=0x1234;
    char* p = (char*)&t;
    char  x = *p;


    According to weaknessforcats , big-endian is "the lowest address has got the MSB" (The big-end in byte 1), and little-endian is "the lowest address has got the LSB" (The little-end in byte 1).

    Let's say our universe is...
    See more | Go to post

    Leave a comment:


  • jorba101
    replied to Endianism
    in C
    Ok.

    So it happens to be the opposite of what I had in mind.

    Anyway, going further:

    In general, if I declare:

    Code:
    char c[1];
    Then, c[0] is the lowest or the highest position? That's what's confusing me.

    Thanks,
    See more | Go to post

    Leave a comment:


  • jorba101
    started a topic Endianism
    in C

    Endianism

    I'm aware of the importance of the concept of endianism, but I don't really know its formal definition.

    In particular, what does mean "big-endian" when applied to network programming?

    i.e., which byte "comes first" from the bus, in a big-endian tx scheme?

    Regarding compilers, for a type of 16 bits, will it make any difference the operation:

    (0xff & ( t_16_data >>...
    See more | Go to post
No activity results to display
Show More
Working...