tech-userlevel archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: updates?
On Jul 25, 8:13pm, charles.cui1984%gmail.com@localhost (Charles Cui) wrote:
-- Subject: Re: updates?
| I have attached the test_signal v2 version, which fills the signal
| reorder function. After we fix the bug that you found,
| we can use this program to test.
Great; I think that the following works too and does not use a temp
array. I have not tested it, and perhaps yours is faster?
christos
/*
* given a array of signals to be delivered in tosend of size len
* place in ordered the signals to be delivered in delivery order
* and return the number of signals that should be delivered
*/
static size_t
sigorder(int *ordered, const int *tosend, size_t len)
{
if (len == 0)
return len;
memcpy(ordered, tosend, len * sizeof(*tosend));
qsort(ordered, len, sizeof(*ordered), compare);
for (size_t i = 0; i < len - 1; i++) {
if (ordered[i] >= SIGRTMIN || ordered[i] != ordered[i + 1])
continue;
for (size_t j = i + 1; j < len - 1; j++)
ordered[j] = ordered[j + 1];
len--;
i--;
}
return len;
}
Home |
Main Index |
Thread Index |
Old Index