Romain Geissler | 15 Apr 2013 09:48
Picon

mq_timedreceive on multiple queues

Hi,

I am currently facing an issue when reading in a set of several posix
queues (let's say 2 different mqueues) from several processes. I
currently use epoll_wait to wait for an incoming message on either
queue on all listening processes, then mq_timedreceive to retrieve it
from the queue.

This is an issue when the number of reader process grows, as if I send
only one message on a queue, all processes are awaken when epoll_wait
returns, and all processes try to fetch the message. I would like to
fix this and wake up only one process when listening to several
queues, removing the useless user/kernel space switchs for the other
listening processes.

Is there any way to run a mq_receive/mq_timedreceive on several
queues, that would wake up only one process? Something more or less
like epoll, but that also fetches a message from the readable queues
before returning.

Thanks,
Romain
--
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo <at> vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Randi Botse | 23 Mar 2013 03:52
Picon

Sending and receiving packets from multiple lines

Hi All,

My network implements interface bonding, aggregate several lines into
one logical line to achieve higher connection throughput and
redundancy.
I'm writing a network application in Linux that basically send packets
to another host outside. I got problem with packet ordering on
destination host, for example. packet1 from line1 should arrived
earlier than packet3 from line3, etc. I want them to be delivered in
correct order. Is this possible? if yes, what is the better way for
doing this?.

Thanks
--
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo <at> vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

SL@maxis | 11 Dec 2012 08:06

post try

Please ignore. Sorry

--

-- 
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/

--
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo <at> vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

ratheesh kannoth | 21 Nov 2012 05:04
Picon

cat a /proc entry

Hi,

is there size limit on the buffer content as i am using  "cat" command
( so ,not allocating any buffer in userspace, so not doing any
copy_to_user from kernel; simply doing  sprintf(buffer, %s , data )
from kernel  for a big data  )

-Ratheesh
--
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo <at> vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Jimmy Pan | 8 Nov 2012 08:01
Picon

How does atomic operation work on smp

I understand how atomic operation work on unary core processors, I think it just disables the interrupt and
dominate the cpu until it finished.
While, how do we implement this on multi processor computers?
Suppose cpu A is performing an atomic operation on variable a. At the same time, cpu B is also performing the
operation on a. In such the result may be overwritten.
Of course we can use spinlocks, but on the atomic operation's behalf, how does it gurantee to prevent such case?
Can anyone explain the crux of it? Thanks.

Jimmy Pan
--
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo <at> vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Randi Botse | 20 Oct 2012 17:03
Picon

String formatting in signal handler

Hi List,

Almost (maybe all) function from the standard library stdio.h and
string.h are not safely to be called by signal handler. If so, how to
format string in a signal handler?. I want to log some signals which
sent to my program, the contents is for example: time, the signal
number itself, etc, and then write it to a file.

Regards.
--
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo <at> vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Randi Botse | 15 Oct 2012 06:50
Picon

UDP message boundary

Hi All

When using TCP socket, I loop send() or recv() until ALL the data has
been transmitted (or error, disconnect, etc.), because TCP socket
packet is transmitted in stream nature, maybe a byte, bytes or all
bytes in one transfer.

The UDP socket preserve message boundary which TCP socket doesn't.
Does this means single call to sendto() will processed by single call
recvfrom()?, and how about packet that exceeds UDP data MAX size?.

So in code, do I need to loop sendto() or recvfrom() to transmit the data?.

Example codes is:

char packet[100];
size_t nbytes = 0;
int ret;

while (nbytes < sizeof(packet)) {
    ret = recvfrom(socket, packet + nbytes, addr, 0,  sizeof(packet) - nbytes);
    if (ret <= 0) {
        /* deal with recvfrom() error */
    }
    nbytes += ret
}

Thanks
--
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
(Continue reading)

Pietro Paolini | 11 Oct 2012 10:44

use getifaddrs()

Hello,

I'm not sure about the mailing list I should ask this.
I am rewrite a C program in order to make it portable between differents arch and I am a bit confused regarding
byte order.

I am getting the list of my interfaces using the getifaddr() functions and it seems return me a list of
interfaces with their IP addresses in network byte order instead of host byte order.
It is a regular behavior or I am wrong and confused ?

Many thanks,
Pietro
--
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo <at> vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Owen Lin (林秀興 | 3 Oct 2012 03:25

(unknown)

         auth efde8f05 subscribe linux-c-programming \
         owen <at> sentelic.com

--

-- 
Regards,
Owen

--
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo <at> vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Ole Bjorn Hessen | 28 Sep 2012 18:11

strace -p <pid> EPERM after root process changed uid/gid to non-root user


Hi,

I have a program that starts as root and changes uid/gid to a non-root
user on linux. I'd like to run strace -p on that process as non-root
but I do only get ptrace(PTRACE_ATTACH, ...): Operation not
permitted. I can send kill to that program though as that non-root user.

Anybody care to explain what magic is neccessary for a root program to
reduce priv level so that an unpriv process can strace -p that program:

Attach is a small program that changes uid from root to "news".
Try to strace that program in another window:

## in window 1

echo '
#include <sys/types.h>
#include <unistd.h>

#define UID 9
int main(char **argv, int argc) {
    setresgid(UID, UID, UID);
    gid_t list[2];
    list[0] = UID;
    list[1] = 0;
    setgroups(1, list);
    setresuid(UID, UID, UID);
    while (1) {
        sleep(1);
(Continue reading)

Randi Botse | 18 Sep 2012 11:29
Picon

Pointer to a char

Hi, having coding in C for 3 years but I'm still not clear with this one.
Consider this code.

...
char *p;
unsigned int i = 0xcccccccc;
unsigned int j;

p = (char *)  &i;
printf("%.2x %.2x %.2x %.2x\n", *p, p[1], p[2], p[3]);

memcpy(&j, p, sizeof(unsigned int));
printf("%x\n", j);
...

Output:

ffffffcc ffffffcc ffffffcc ffffffcc
0xcccccccc

My questions are:

1. Why it prints "ffffffcc ffffffcc ffffffcc ffffffcc"? (if p is
unsigned char* then it will print correctly "cc cc cc cc")
2. Why pointer to char p copied to j correctly, why not every member
in p overflow? since it is a signed char.

Regards.
--
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
(Continue reading)


Gmane