With this PHP code, what do you expect is the resultant error level?
The answer is ‘1’. After main() calls exit( 0 ) the shutdown function shutdown_1() is invoked. When shutdown_1() calls exit( 1 ) the process exists and shutdown_2() is never called.
The context object unifies the handling of all system-global information and eliminates the need for pass-through variables. If a new variable needs to be added, it can be added to the context object; no existing code is affected except for the constructor and destructor for the context. The context makes it easy to identify and manage the global state of the system, since it is all stored in one place. The context is also convenient for testing: test code can change the global configuration of the application by modifying fields in the context. It would be much more difficult to implement such changes if the system used pass-through variables.
Contexts are far from an ideal solution. The variables stored in a context have most of the disadvantages of global variables; for example, it may not be obvious why a particular variable is present, or where it is used. Without discipline, a context can turn into a huge grab-bag of data that creates nonobvious dependencies throughout the system. Contexts may also create thread-safety issues; the best way to avoid problems is for variables in a context to be immutable. Unfortunately, I haven’t found a better solution than contexts.
Okay, so I’m just gonna step way out of line over here and suggest something heretical… but shouldn’t you just use global variables? You only introduced the context object so you could tweak it in unit tests, and you could just change your tests so that each one ran in a new process. Just sayin’.
…I suppose for the sake of completeness I should add a little more from Ousterhout which he said prior to the above:
Another approach is to store the information in a global variable, as in Figure 7.2(c). This avoids the need to pass the information from method to method, but global variables almost always create other problems. For example, global variables make it impossible to create two independent instances of the same system in the same process, since accesses to the global variables will conflict. It may seem unlikely that you would need multiple instances in production, but they are often useful in testing.
…so he is bending over backward to support multiple tests in one process, but he could just run each test in its own process and his problem evaporates.
Man. So. Today, this happened. I was watching a new video from Adrian Black and his EEVBlog multimeter failed:
I have been saving my pennies and planning to buy an EEVBlog 121GW Multimeter because a lot of the makers around the interwebs have one as a nod to Dave Jones over on the EEVBlog, but that’s just so embarrassing that it’s failing. Of all the equipment you have you need to trust your test equipment the most and this is… well, just sad I guess.
In this video I do the third Maxitronix 10in1 Electronic Project Lab project: Diode Experiment.
When I looked at the resistor on the bottom I thought it was red – brown – black – gold which would have been 21Ω but I think I misread brown and that was actually purple which would be 27Ω which stacks better with the two measurements I made both of which said 27Ω.
In the video we examine the forward voltage of our germanium diode and get various readings. Typically a germanium diode should be around 0.3V versus silicon diodes which are usually around 0.7V.
On the FNIRSI component tester the Ir is the “reverse current”, also known as the “leakage current”. This is the small amount of current which flows through the diode when it is reverse biased (that is, basically, connected the wrong way around).
I asked ChatGPT a few questions about diodes and their specifications which you can read here: Germanium Diode Forward Voltage if you’re at all interested in such things. Of course you should be doubly suspicious of anything you read on the internet. :)
The really amazing learning for me in this experiment was how hot the germanium diode got versus the lamp, which was so surprising. Just goes to show how good an idea it is to actually do experiments and measure things! The thermal imager we used was the UNI-T UTi260B.
Also I think I’m coming around to the view that an oscilloscope is a pretty poor voltmeter. My oscilloscope is an MSO5074 70MHz 4 Channel MIXED SIGNAL OSCILLOSCOPE and I love it but I think in future I will limit my use of the oscilloscope to situations where I’m actually dealing with some sort of oscillator. I think simple digital multimeters would have been better test equipment to use for the kinds of readings I was trying to take in this experiment.
I hope you enjoy the video. Stay tuned for the upcoming projects. If you’re interested in seeing them don’t forget to subscribe!
Also, if you’re interested in getting any of these Maxitronix kits yourself the best place I know to look is on eBay. Let me know if you find them somewhere else!
Thanks very much for watching! And please remember to hit like and subscribe!
Following is a product I use picked at random from my collection which may appear in my videos. Clicking through on this to find and click on the green affiliate links before purchasing from eBay or AliExpress is a great way to support the channel at no cost to you. Thanks!
I found the following four videos on the AlphaPhoenix channel explaining various aspects of the propagation of electricity, which goes some way to explaining how the high impedance headphone might work in my 10in1 2/10 project.
Man. I would really like to own a scope which could measure signals at 1GHz or more. Like this RIGOL DS70504 which can do 5GHz. The only problem is the price tag: AU$52,928.99. :(