[CSOUND-DEV:3324] Road to Reentrancy
Date | 2003-11-16 06:02 |
From | stevenyi |
Subject | [CSOUND-DEV:3324] Road to Reentrancy |
Hi all, I was talking with Matt about the reentrancy stuff and replacing use of the global cglob with a passed in cglob. I wanted to outline the steps required to get Csound reentrant as it looks to me. I'm pretty sure I'm not seeing the whole picture and the things that were already set in motion by John and others, so feel free to correct me. The current sources seem to already setup a lot of the work necessary, as previously global data has been moved to the GLOBAL cglob. I was thinking the steps forward would be: 1)Use csound.c instead of jpff_glue.c. csound.c is better set up to use the API as the functions are all implemented. Also, using ccsound.c would be essential, as it uses the API. This is important to do for later steps. 2)Remove use of #defines that map to cglob, one by one, and do a global find and replace to manually replace calls. This basically does what the cglob-mapping defines do using the preprocessor. 3)Rename cglob to something else, thus removing it from the global scope. This will be the big break. After this, it's a matter of adding the passing of cglob down the chain of function calls so that every function that needs cglob will get it. Renaming cglob would be necessary as an intermediate step as csoundCreate, which currently passes a reference to cglob, would pass the reference to the renamed cglob. This step sets up the functions of csound to handle being passed in cglob, but does not yet remove the use of a GLOBAL * in the global space. 4)Change csoundCreate to allocate a new GLOBAL * and remove the renamed cglob from the global scope. I'm not sure if this was the original plan or what, I'm just wanting to clarify if I've understood what's required correctly. If this is looking good, then I'll probably start on doing some of the global find-and-replacing in step one, little by little. thanks all, steven |
Date | 2003-11-16 08:24 |
From | "Matt J. Ingalls" |
Subject | [CSOUND-DEV:3329] Re: Road to Reentrancy |
> 2)Remove use of #defines that map to cglob, one by one, and do a global > find and replace to manually replace calls. This basically does what > the cglob-mapping defines do using the preprocessor. > > 3)Rename cglob to something else, thus removing it from the global > i would just do 2 & 3 at once. i just tried this with csound4 sources and got over 3000 errors -- and it looks like that it only attempted compiling about half the files.. so it may end up being A LOT of work to chance every function that uses an ex-global variable to take a passed GLOBALS struct. the other option [as steven and i already discussed] would be to just swap cglob structs on every API call -- you would have to put up blocks for multiple instances, but it could be MUCH easier than the other option... -m |
Date | 2003-11-16 10:34 |
From | Richard Dobson |
Subject | [CSOUND-DEV:3331] Re: Road to Reentrancy |
This was one of the early goals of the code-freeze, so I am very happy to see everyone ready to deal with what is clearly an arduous and time-consuming job! Getting return values from opcode fucntions is part of it of course, but re-parametrizing the functions is the other and even bigger task. My one suggestion (in the absence of inspecting the sources just as I write) is that there will be many situations where a particular subset of global variables travel around together - not least, everything associated with the orch header info. These are worth wrapping into mini structures; in many cases there will be no need to pass the whole GLOBALS struct, but individual elements, or a particular group of them. Conversely, I beleive there may be opportunities to eliminate many items from GLOBALS altogether, that really have no business being there (i.e. truly private to the internals of Csound), as their presence was merely a classic C way of avoiding writing functions structured into levels. In short, I hope we can use this opportunity to further restructure the code, not just addrress the issue of re-entrancy. Richard Dobson Matt J. Ingalls wrote: >>2)Remove use of #defines that map to cglob, one by one, and do a global >>find and replace to manually replace calls. This basically does what >>the cglob-mapping defines do using the preprocessor. >> >>3)Rename cglob to something else, thus removing it from the global >> > > > i would just do 2 & 3 at once. i just tried this with csound4 sources and > got over 3000 errors -- and it looks like that it only attempted compiling > about half the files.. > > so it may end up being A LOT of work to chance every function that uses an > ex-global variable to take a passed GLOBALS struct. the other option > [as steven and i already discussed] > would be to just swap cglob structs on every API call -- you > would have to put up blocks for multiple instances, but it could be MUCH > easier than the other option... > > -m > > |
Date | 2003-11-16 20:18 |
From | stevenyi |
Subject | [CSOUND-DEV:3340] Re: Road to Reentrancy |
I was thinking about this this morning and I think it might be possible to replace the two OENTRY arrays with blanks and remove most of the opcodes from compiling in the Makefile to then just concentrate on finding where it'd be necessary to pass cglob down the functions. Either that, or doing this with Csound5 CVS stuff probably wouldn't be as bad as non-necessary opcodes have already been moved by John to opcode plugins. Thinking about it all more I think I'm more in line with Richard and Michael regarding "biting the bullet" and just going ahead and trying to find all the calls and passing things down the line. It's going to be better for multi-instance performance as well as two or more running instances of csound won't block each other. steven On Sun, 2003-11-16 at 00:24, Matt J. Ingalls wrote: > > 2)Remove use of #defines that map to cglob, one by one, and do a global > > find and replace to manually replace calls. This basically does what > > the cglob-mapping defines do using the preprocessor. > > > > 3)Rename cglob to something else, thus removing it from the global > > > > i would just do 2 & 3 at once. i just tried this with csound4 sources and > got over 3000 errors -- and it looks like that it only attempted compiling > about half the files.. > > so it may end up being A LOT of work to chance every function that uses an > ex-global variable to take a passed GLOBALS struct. the other option > [as steven and i already discussed] > would be to just swap cglob structs on every API call -- you > would have to put up blocks for multiple instances, but it could be MUCH > easier than the other option... > > -m > > |
Date | 2003-11-17 12:14 |
From | jpff@cs.bath.ac.uk |
Subject | [CSOUND-DEV:3357] Re: Road to Reentrancy |
>>>>> "stevenyi" == stevenyi |