tech-userlevel archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: updates?
Hi Christos,
This patch fixed the bug you found
https://github.com/ycui1984/posixtestsuite/blob/master/patches/REALTIME_SIGNAL/0006-bug-fix-for-real-time-signals.patch
2016-07-25 21:33 GMT-07:00 Charles Cui <charles.cui1984%gmail.com@localhost>:
> yeah, it seems correct,
> my solution use another array, so space complicity is O(n), time
> complicity is O(nlogn) for sorting and O(n) for copying to new array. Your
> solution has space complicity O(1), time complicity is O(nlogn) + O(n^2).
>
> 2016-07-25 20:24 GMT-07:00 Christos Zoulas <christos%zoulas.com@localhost>:
>
>> 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