[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lwip-users] Question about sys_arch.c *_free() vs. *_~set_invalid()
From: |
Grant Edwards |
Subject: |
[lwip-users] Question about sys_arch.c *_free() vs. *_~set_invalid() |
Date: |
Thu, 11 Nov 2021 21:00:40 -0000 (UTC) |
User-agent: |
slrn/1.0.3 (Linux) |
[Sorry for all of the porting questions, but the sys_arch.c file I'm
working with just doesn't seem to make sense.]
I don't understand how *_free() and *_set_invalid() are supposed to
interact.
In the code I've inherited, when *_free() is called, my sys_arch.c
code places the referenced kernel object (semaphore or mailbox) back
into the free pool and it becomes available to be reallocated and
placed into use.
The lwIP documentation states:
void sys_sem_set_invalid(sys_sem_t *sem)
Invalidate a semaphore so that sys_sem_valid() returns 0.
ATTENTION: This does NOT mean that the semaphore shall be
deallocated: sys_sem_free() is always called before calling this
function!
Apparently the sequence is
new(sem)
free(sem)
invalid(sem)
If invalid() is called for a particular semaphore _after_ that
semaphore has been free()ed, that semaphore may have already been
reallocated and might be in use by a different thread, socket,
whatever. Is the semaphore not supposed to be availble for
reallocation after being free()ed?
Are signal/wait calls on a mutex allowed between the free() call and
the set_invalid() call?
--
Grant
- [lwip-users] Question about sys_arch.c *_free() vs. *_~set_invalid(),
Grant Edwards <=