Messages in this thread | | | Date | Sat, 16 Jan 1999 02:24:17 -0500 | From | Chip Salzenberg <> | Subject | Re: C++ in kernel (was Re: exception in a device driver) |
| |
According to Alexander Viro: > On Sat, 16 Jan 1999, Chip Salzenberg wrote: > > template <semaphore_t *SEM> > > class hold { > > public: > > hold() { down(SEM); } > > ~hold() { up(SEM); } > > }; > > > > void random_function() > > { > > hold<&one_semaphore> hold1; > > hold<&other_semaphore> hold2; > > // ... > > } > > And if you'll call something that will throw an exception here it > will compile to?
That's target-environment-dependent. The ELF object format provides enough structure to assist in automatic cleanups; other environments require cleanups to be done in ways more like hand-written C.
BTW, there are many places where you > * release the lock on different pathes. > * don't want to hold it too long. > * release it from another function, called by you. > * have to release a spinlock before the blocking operation. > * have scopes incompatible with syntax ones,
A bit of code rearrangement can be required, yes. TANSTAAFL. -- Chip Salzenberg - a.k.a. - <chip@perlsupport.com> "When do you work?" "Whenever I'm not busy."
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
| |