Tech posts by aclassifier
Also see Øyvind Teig site

You are at http://oyvteig.blogspot.com
Archive by month and about me: here
Last edit: 4Sept2015
Started move: September 2012
All updates at http://www.teigfam.net/oyvind/home/, but the overview is updated

Sunday, January 17, 2010

007 - Synchronous and asynchronous

Original posting


Intro and quotes

Observe that in 2010 the "action" goes on at the comment and bottom level of this post!

[1] caused me to write this post because I stalled at some of the paragraphs. The authors hit a chord in my favourite mantra - a computer programmer should be fluent at both asynchronous and synchronous systems, and know the pros and cons, necessities and unnecessities of both. I guess that I in this post will try to outline what systems means in this context.

I will start with the quotes from [1]:
[1.1] - "The flexibility required of this missions could not have been accomplished in real time without an asynchronous, multiprogramming operating system where higher priority processes interrupt lower priority processes."
[1.2] - "To our surprise, changing from a synchronous OS used in unmanned missions to an asynchronous OS in manned missions supported asynchronous development of the flight software as well."
[1.3] - "Lessons learned from this effort continue today: Systems are asynchronous, distributed, and event-driven in nature, and this should be reflected inherently in the language used to define them and the tools used to build them."
[1.4] - "Async is an example of a real-time, distributed, communicating FMap structure with both asynchronous and synchronous behavior."
Disclaimer 1: This paper is not a review of [1]. Parts of it was a catalyst to structure some of my own thoughts, many of them are not even mine. I should say again because I have done this over and over. The real theme of [1] I have not even mentioned: the Universal Systems Language (missing Wikipedia page (wrong: it has arrived after my original post [wikipedia] and [12])). The structure(?) of this post is such that I have a virtual dialogue with the authors - based on the quotes above.
Disclaimer 2: This is not a scientific paper - it is a post on a blog.
[1.1] - Synchronous vs. asynchronous OS
[1.1] - "The flexibility required of this missions could not have been accomplished in real time without an asynchronous, multiprogramming operating system where higher priority processes interrupt lower priority processes.
I am not certain what the authors mean with asynchronous, multiprogramming operating system as opposed to a synchronous OS.

But I will give it a try. I assume that in a synchronous OS, the processes (also called tasks) run in some sort of slot, like some milliseconds each. They have to finish their work in their slots, so that the next slot is not delayed. This is not a side effect, it's the whole idea. One process then is not able to interrupt any other - since they run in sequence. Maybe even asynchronous I/O (like polling of interrupt sources) are assigned a slot. With such a system there is no problems with shared access, so semaphores are not needed. Things seem simple.

However, there are several process scheduling algorithms for this [wikipedia]. I assume that some of these would fall into the synchronous OS category. One such scheduling policy could be rate monotonic - where "tasks with shorter periods/deadlines are given higher priorities" [wikipedia].

I feel confident that the authors did not mean that systems - such as those programmed in Ada, with synchronous rendez-vous or channel communication schemes - constitute a synchronous OS at the scheduler level.

Or I could be wrong, and a synchronous OS is the one such that runs and schedules programs of the synchronous programming language type [wikipedia]?

Synchronized OS as using synchronous communication is probably not what they mean - but asynchronous OS and asynchronous communication might be paired in [1]. However, I hope synchronization and OS are orthogonal, also in the paper.
[Def 1] - So I hope that an "asynchronous operating system" could include an Ada-style system without any visible "OS" at all. In the following I have assumed this.
[1.1] again - Required flexibility
[1.1] - "The flexibility required of this missions could not have been accomplished in real time without an asynchronous, multiprogramming operating system where higher priority processes interrupt lower priority processes.
If the authors, with asynchronous, multiprogramming operating system mean that communication mechanism between tasks mostly is based on asynchronous messaging, then I need more explanation than [1] gives me.

However, I think that this is not what they mean. They simply mean that asynchronous OS is not synchronous OS - and that messages (events) between processes drive the system. It's not the passing of a big clockwork that displays time, like the inner machinery of Big Ben in London, where all wheels are synchronous. It's more like the combined effort of any workforce with a loose degree of central control.

The communication mechanism between processes is rather crucial. Some mean that asynchronous communicating (send and forget) and a common message buffer solves their need. Some would say a synchronous communication mechanism solves their need (channels or Ada-like rendez-vous). The latter is often seen as rather stiff or rigid, and I dare to say, little understood. I have written a paper about this: CSP: arriving at the CHANnel island - Industrial practitioner's diary: In search of a new fairway [2].

Using an asynch message scheme would cause a process to have to know how the internal programming in the other processes work. Here is a quote from [3] - which discusses an alternative to the non-Ada type communication scheme, the Java monitor synchronization mechanism:

One crucial benefit of CSP is that its thread semantics are compositional (i.e. WYSIWYG), whereas monitor thread semantics are context-sensitive (i.e. non-WYSIWYG and that's why they hurt!). Example: to write and understand one synchronized method in a (Java) class, we need to write and understand all the synchronized methods in that class at the same time -- we can't knock them off one-by-one! This does not scale!! We have a combinatorial explosion of complexity!!!

CSP is not out of scope here - Ada's rendes-vous is based on CSP [5]. The WYSIWYG is also discussed in [4].

Bear in mind that communication scheme and degree of synchronization are closely related. With zero buffered synchronous channels, communication is synchronization. With buffered asynchronous-until-full channels, synchronization happens when the channel reaches capacity and becomes synchronous. When the channel size is infinite, synchronization never happens - or it does not happen before a sender at application level waits for a response, i.e. inserts synchronization.

Different programmers tend to chose different methodologies here. Or the traditions and earlier usage in different companies. Or changing times. My previous post '006' will try to discuss this.

There are also several other points, like the producer / consumer problem. Here, buffers would fill up (to overflow?) on a faster producer than consumer. Also, with messages flowing into a process, there may be no system to stop a message from arriving. With input guards and synchronous communication it's possible to close the door from a client, to finish off a session with another client - undisturbed by the fact that another message is waiting outside the door. An important building block.

However, since the world is basically asynchronous, it is important that programmers know the different tools and methodologies. Synchronous communication may be built on top of an asynchronous layer - and opposite. I will come back to this. Deadlock (synchronous) and pathological buffer overflow (asynchronous) must be avoided. This is exciting!

[1.2] - Loosely coupled development teams
[1.2] - "To our surprise, changing from a synchronous OS used in unmanned missions to an asynchronous OS in manned missions supported asynchronous development of the flight software as well."
If one of the systems I have been working on is in fact an asynchronous OS, but with synchronous communication (channels) layered on top - and that is the same as the above (assuming [Def 1]), we probably have experienced the same. I have written a paper about this: High Cohesion and Low Coupling: the Office Mapping Factor [6].

I argue that the higher cohesion in each process (they each do a well defined job), and the less coupling (with synchronous communication and WYSIWYG semantics) - the easier it seemed to be for programmers to agree on the interface contract (the message sequences or protocol) - and then enter the office and do the job. There was little need to discuss any more.

My paper is a case observation from industry - so the Office Mapping Factor is only a hypothesis until somebody takes the token and carries on.

In [1.2] there is a term, asynchronous development, which needs a definition. I think they talk about decoupling of the development members and teams as much as possible from each other. My gut feeling is that this is the same as my Office Mapping Factor. However, if they base their software on asynchronously communicating processes - then, they would perhaps get even better yield by using [Def 1] - Ada-type communication.

If the Ada designers had used named rendez-vous or named channels to communicate between processes, instead of named endpoints, it would have been even easier to build good libraries. C.A.R. Hoare, in his second CSP book of 1985 (ref. in [5]) took the channels to be named entities that could be ripped up and placed anywhere - in run-time. A process communicates on a named channel (like on an ip-address), not with another named process. This was about the same time that that Hoare (with fellows at Oxford University) together with people at Inmos (David May etc.) had built a runnable instance of CSP, the programming language occam [7] and a processor for it, called a transputer. It would be wrong of me not to admit that it is from those sources and fellow admirers I have been drinking, from about 1980 to this very day.

This would make the programmer's interfaces (API) better, and well defined message sequences with WYSIWYG semantics - tools for getting "asynchronous development" with high Office Mapping Factor.

[1.3] - Systems are increasingly asynchronous
[1.3] - "Lessons learned from this effort continue today: Systems are asynchronous, distributed, and event-driven in nature, and this should be reflected inherently in the language used to define them and the tools used to build them."
Now I really begin to doubt that [Def 1] is anything but a misinterpretation in the context of [1]. Because, yes, there is a trend. I saw a web page of a high profile lecturer who should have a one day course. One of the points was Running tasks in isolation and communicate via async messages. Then I queried on a discussion group, and one in the community said that:

"Most likely it's the fire and forget and hope the buffer doesn't overflow variety - Erlang style concurrency. This seems to be the current method everyone is interested in (Erlang, Scala actors, F# Async Mailboxes, Microsoft Concurrency and Coordination Runtime). There is sometimes some form of guard available, be it one that allows checking of the incoming message, or selection of one from multiple inputs."

Maybe this is what the authors refer to. Or something along that line.

When they talk about language, I am sure they mean the language described in [1], USL. With solid semantics, and if the semantics is well enough defined, it does not matter if it's based on synchronous or asynchronous communication? Like, Harel State Charts in UML are based on asynchronous communication between state machines. And it's pretty solid, and it doesn't really void formal verification, it seems. Of course it is possible to build good systems with this, both unmanned and manned missions of any literal kind.

But maybe, if the same designers knew as well about the [Def 1] style systems as they do with the asynch OS / asynch communication schemes, we would get even better systems? To introduce a world where it's understood that you cannot simulate or visualize a system to be error free. Some tools now do verification: IAR's Visual State (of UML state machines), Spin (of Promela models) and FDR2 (of CSP), as well as LTSA (of FSP) analysis, see [8]- [11].

[1.4] - Joining heads for synch and asynch?
[1.4] - "Async is an example of a real-time, distributed, communicating FMap structure with both asynchronous and synchronous behavior."
Now, what does this mean? If it's asynchronous OS and synchronous OS behavior, it would sound strange to me. According to Turing, any machine can run on any other. Laid out here: asynch or synch OS may be built on each other. So, the behaviour should really be the same? If MS Word runs on Mac OS X or Windows the behaviour is the same? (well, almost..)

Instead, I have a hypothesis that they this time talk about asynchronous and synchronous communication behaviour? Then it makes more sense to me to talk about different behaviour.

Any software engineer should know these methodologies (tools), know the strengths and weaknesses of each. When it's appropriate to use one instead of the other, and how combinations could be used.

I will not sum up here. I have glimpsed through some points, seriously tearing and wearing on the [1] paper, and used it as a catalyst. I have written about these things for years. Being incomplete as it is, there may be some points in some of my papers, at http://www.teigfam.net/oyvind/pub/pub.html. Maybe I will try to sum up in a future posting.

References

[1] - Universal Systems Language: Lessons Learned from Apollo. Margaret H. Hamilton and William R. Hackler, Hamilton Technologies, Inc. In IEEE Computer, Dec. 2008 pp. 34-43 ("USL"). The authors have commented on this blog, see [C.1] (below).

[2] - CSP: arriving at the CHANnel island - Industrial practitioner's diary: In search of a new fairway. Øyvind Teig, Navia Maritime AS, division Autronica. In "Communicating Process Architectures", P.H. Welch and A.W.P. Bakkers (Eds.), IOS Press, NL, 2000, Pages 251-262, ISBN 1 58603 077 9. CPA 2000 conference (In the series: "WoTUG-23"), Communicating Process Architectures, University of Kent at Canterbury, UK, 10-13. Sept. 2000. Read at my home page at http://www.teigfam.net/oyvind/pub/pub_details.html#CSP:arriving_at_the_CHANnel_island

[3] - Letter to Edward A. Parrish, The Editor, IEEE Computer. Peter Welch (University of Kent, UK) et al. dead url: http://www.cs.bris.ac.uk/~alan/Java/ieeelet.html (1997), internet archive at http://web.archive.org/web/19991013044050/http://www.cs.bris.ac.uk/~alan/Java/ieeelet.html (1999)

[4] - A CSP Model for Java Threads (and Vice-Versa). Peter Welch. Jeremy M. R. Martin. Logic and Semantics Seminar (CU Computer Laboratory) (2000) - http://www.cs.kent.ac.uk/projects/ofa/jcsp/csp-java-model-6up.pdf

[5]- CSP - Communicating sequential processes - http://en.wikipedia.org/wiki/Communicating_sequential_processes

[6] - High Cohesion and Low Coupling: the Office Mapping Factor. Øyvind Teig, Autronica Fire and Security (A UTC Fire and Security company). In Communicating Process Architectures 2007. Alistair McEwan, Steve Schneider, Wilson Ifill and Peter Welch (Eds.). IOS Press, 2007 (pages 313-322). ISBN 978-1-58603-767-3. © 2007 The authors and IOS Press. Read at http://www.teigfam.net/oyvind/pub/pub_details.html#TheOfficeMappingFactor

[7] - The occam programming language - http://en.wikipedia.org/wiki/Occam_(programming_language)

[8] - IAR's Visual State (of UML state machines) - http://en.wikipedia.org/wiki/IAR_Systems

[9] - Spin (of Promela models) - http://en.wikipedia.org/wiki/Promela

[10] - FDR2 (of CSP models) - http://www.fsel.com/

[11] - LTSA (of FSP models) - http://www-dse.doc.ic.ac.uk/concurrency/

[12] - Universal Systems Language - http://en.wikipedia.org/wiki/Universal_Systems_Language

New References from the Comments section (below)

[13] - A Comparative Introduction to CSP, CCS and LOTOS, Colin Fidge, Software Verification Research Centre Department of Computer Science, The University of Queensland, Queensland 4072, Australia, January 1994 - http://ls14-www.cs.tu-dortmund.de/main/images/vorlesungen/KomSer/uebungen/csp-ccs-lotos-fidge94g.pdf

[14] - Metric spaces as models for real-time concurrency,G.M. Reed and A.W. Roscoe, Oxford University Computing Laboratory - http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.97.1311&rep=rep1&type=pdf

[15] - Concurrent Logic Programming Before ICOT: A Personal Perspective, Steve Gregory, Department of Computer Science, University of Bristol, August 15, 2007 - http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.88.3100&rep=rep1&type=pdf

[16] - http://oyvteig.blogspot.com/2009/03/009-knock-come-deadlock-free-pattern.html - "009 - The "knock-come" deadlock free pattern" blog here.

[17] - "3. Asynchroneous services for OpenComRTOS and OpenVE" in Altreonic News Q1 2010-1, http://www.altreonic.com/content/altreonic-news-q1-2010-1

Comments

[C.1] - Comments by the Authors of [1], Dec.2009

This post has been commented by the Authors of [1]. The comment has been approved for public reading. Read at http://www.teigfam.net/oyvind/blogspot/007/ieee_teig_notes1.htm.

Thank you for the comments!

I'd certainly like others to comment in this blog! I will try to follow up myself.

[C.2] - CSP and "true concurrency" 

Comment [C.1] states that "Note, that for any of the process algebras (CSP, CCS or LOTOS) "parallelism" is a misnomer (see Receptive Process Theory); none of the process algebras support "true" concurrency, only interleaving, see.." [13] page 12.

Page 46 of [13] reads: "True concurrency semantics. Although conceptually simple the interleaving semantics used by the process algebras mean that the “concurrency” operators are not fundamental and hinder the ability to add time to the languages. True concurrency semantics, in which traces become only partially ordered, have been suggested as a more accurate model of concurrency. There are two principal methods: multi-set traces use linear traces with a set of actions listed at each step; causally ordered transitions maintain pointers denoting causal relationships between events in the traces."

This puzzles me, especially since I am a programmer, and not a computer scientist, and therefore would not know the answer. However, I have been running occam on multi-transputers in the nineties, and those processes of course had true parallelism, and not pseudo concurrency. When placing the same processes on a single machine, I certainly experienced their semantics not to change. Occam had "parallel usage rules", helping me to obey CREW (concurrent read, exclusive write) on say, segments of a shared array.

In [14] (page 12) it says: "The semantics we gave for CSP is by no means the only possible one that is reasonable..". "Also both the parallel operators we gave were true parallel operators, in that the time taken by the two operands was not summed: one might well need time-sliced pseudo-parallel operators in applications." Does this contradict the page 46 quote from [13] above?

And [15] says "It seemed reasonable to replace both coroutining and pseudo-parallelism by “real” concurrency, using CSP-like input (match) and output (bind) operations on channels (shared variables)."

From theory to practive. I see no way where parallel processes could run in true parallel on a uni-processor machine. Instructions have to interleave on that implementation level. Not even interrupt (processes) are truly parallel. Moving to a multi-core would help. But all software processes need to communicate. If this is done by "send and forget" or "move data during blocking rendezvous", I don't see that any of this would move a process into being not truly concurrent and only interleaving.

See from this programmer's head, when two processes are not communicating on a CSP blocking channel, they are really running truly concurrently! And when they do communicate (and synchronize), that's what they do, and true or pseudo concurrency is not even asked. It's in a different problem domain.

I need help! Even if I, to a certain point, don't care if my runnable processes would be considered pseudo or real. To me I have mostly learnt them to know as both.

However, for formal language tool (like Promela) processes I guess it certainly matters.
(17Jan10)

[C.3] - USL Distributed Event Driven Protocol

This is described at comment [C.1] above.

I got a complete surprise when I saw this: it's quite close to my "The "knock-come" deadlock free pattern" [16]. The wording is different, but the essence is the same: tell that you have something ("knock"), then wait for a reply saying "come" - then send the data.

The USL now, is it a "language around this pattern"?

Since USL seems to build on this pattern, almost everything changes in my comments!

[16] is a back-to-back pattern that I have proven with Promela/Spin to be deadlock free.

And the protocol is why, in USL "There can never be overflow; faster producers and slower consumers are never an issue". Of course! (That being said, a faster producer than consumer is an application level problem which must still be solved at that level.)

Now, is it I that have turned synchronous into asynchronous (my "come" is sent on an asynchronous interrupt channel with no data), or USL that, inside the engine, really is synchronous? They say: we can push the accelerator any time, and I say: but the crankshaft makes ignition synchronous! Are we saying sort of same thing?

Also, when USL says that "[1.2] - To our surprise, changing from a synchronous OS used in unmanned missions to an asynchronous OS in manned missions supported asynchronous development of the flight software as well." - I have to agree! I have said the same of "my" architecture! See [6] "High Cohesion and Low Coupling: the Office Mapping Factor."

So, it's true that the process, communication and synchronization "concurrency building blocks" certainly show up in the final software architecture. A wooden and a brick house look different and have different qualities.

Next, I should study Universal Systems Language built "around" the USL Distributed Event Driven Protocol. I think I have discovered the canvas of this painting. Then I need to find out at which distance I should relate to it. As a reader, viewer or ..painter?

I have now added a comment to [16].
(18Jan10)

[C.4] - Another synchronous/asynchronous comment

The company Altreonic in [17] (above) explains about their OpenComRTOS in a newsletter:
"The asynchronous services are a unique type of service as they operate in two phases. In the first phase the application task (or driver) issues a request to synchronize or pass on data via an intermediate hub entity. This request is non-blocking and hence the task can continue. Later on it can wait for the confirmation that the synchronisation or data exchange has happpened. A task can simultaneously have multiple open requests using one or more hub entities. This is valid for sending as well as receiving tasks and provides a very flexible and efficient mechanism. Safety is assured by the use of a credit system."
My boss at work sent me the newsletter, wondering if this was perhaps in the same street as the "knock-come pattern". I got a feeling of rememberance, because I had talked with people from Altreonic for many years at CPA conferences, from the Eonic days and even before that, when some of us were using transputers, and quite a few occam.

So, this street seems to have several buildings: The USL protocol, The OpenComRTOS and even our knock-come when used as we use it - together with a small, embedded data base. And certainly there must be many more!

I sent a mail to Altreonic and queried. A thread followed with Eric Verhulst, who wrote (he allowed me to quote):
"I remember we had our discussions many years ago when Eonic was promoting Virtuoso. Already at that time there was a discussion whether Virtuoso violated the strict rules of CSP. At that time I called it a “pragmatic” superset of CSP. The work done on OpenComRTOS (whereby we used formal modeling) has proven that this intuition was right. I think it has also "solved" the synchroneous-asynchroneous debate.  It is not an XOR debate or an AND debate. At the lowest level of the primitive operations, it is synchroneous. At the higher semantic levels we can introduce asynchronisity. That good thing is this is not in conflict at all with CSP."
What more is there to say? Personally I started this blog with quarreling about sync versus asynch. Like in The Alchemist by Paulo Coelho there was something to return back to: maybe it's not that simple: "sync versus asynch".

What more to ask: "at what level and for what usage?"

There is no use to repeat  comment [C.3] above. But maybe the general idea holds as a comment also here.

There is more to the OpenComRTOS story, though: the consequence which their hub has on the safety of the application. The use of the knock-come pattern, use of the USL protocol and the use of the two-phase hub mechanism of OpenComRTOS seem to all help with this. It's "send and not forget" or "send and forget but then be reminded again". For certain needs this is great stuff. Especilally if one needs to send off lots of data or commands to wherever, let them do their anyway(?!), even at much much slower speeds, and then get the result. The idea then is to both report how it went, and not to get empty of memory for this stuff. No crash. Limits are handled by design. OpenComRTOS do static linkage of packets with no malloc, with blocking if there is no packets left.

Alternatively one could have a data bank with enough entries for each request or command and then tag the elements with status, like: want to send down, is expecting reply etc. This is how we did it in an embedded product: with success - but the knock-come pattern was used in connection.

A synchronous channel is really a handle to common data. With space for no packets, the receiver may hold the producer. With zero data there could be an asynchronous "interrupt" channel and asynchronous send. With some space in the channel, it would block when it's full. With Ada rendezvous, data exchange is synchronous (blocking) and bidirectional. The channel concept evolves, it could be one-to-many or many-to-one, and they could be connected to a mechanism like a barrier synchronization mechanism.

However, what I would look for is to have WYSIWYG semantics: no matter how asynchronous the mechanism I use, I would want to only relate to the defined protocol between the concurrent processes. I will not need to know how that other process is coded internally. Think about this: if I hold a channel (or whatever input mechanism) while I do the session I was just told to start (I am a server), am I allowed to send the result back to the originator client that used me, and not think a second about how that would influence the other clients competing for me? And the clients, could they be coded 100% irrelevant of the server code, provided they agree on the interface contract?

Am I allowed to control my clients myself, to make handling "fair"? Do I have the mechanism? Will this system behave the same way if I use a client with a statically linked channel, across the internet, or on a channel sent over a channel. Have a look at occam-pi for these things, look at the Go programming language, read the CPA-someyear literature (Communicating Process Architecture poceesings).

Read papers you seem to disagree with. Study newsletters from interesting companies.

There is much more out there than just send and forget.
(11Feb2010)

--


Monday, July 20, 2009

014 - Notes about iPhone

Please observe that this note, even if started on July 20, 2009 has been extended with several sub-posts that are being continuously updated (last in 6Mar11)

Being a software engineer (with some older hw skills mingling about), I am used to collecting lists of errors, problems and ideas. Here is my list for my iPhone. I have an iPhone 3G, quickly updated to latest upgrade from Apple. At the moment I have sw version 4.21, build 8C148, but the problems below have been tagged with actual versions of the time. Please also note that my experience here is with Mac machines, not with say, iTunes on Windows.

I will try to update the list when the problems have been fixed as seen from my iPhone. I also have some other iPhone posts in this blog. My goal is to try to help getting a great mobile phone even better!

Disclaimer: I try to be accurate and not confuse here. But what I say may not be correct for your configuration, iPhone or machine. Some times I do arrive at conclusions, but I try not to jump on them. Still I might have! I would certainly appreciate comments of any serious sort!

iPhone Troubleshooting Assistant etc.
Observe Apple's at iPhone Troubleshooting Assistant. Pages there lead you safely through scary encounters like restoring the phone. Don't be afraid, the procedures are as elegant as the rest. Bear in mind that data belonging to your AppStore are not any "restored", but reappear on your next synchronization. (Norwegian: Problemløsingsassistent for iPhone)
Also notice chapter 7 - Disappearing iPod/iPhone from machine (iBook) here, ref [2].
1 - "Empty" Camera Roll (closed for Mac/Windows users, open? for Apple)

16 - iPhone synching picture fails on 3G, not 3GS
See http://oyvteig.blogspot.com/2010/09/020-mac-os-x-network-disk-partially.html, chapter "Related problem - iPhone synching picture fails on 3G, not 3GS"
15 - Spacebar double-tap to close brackets?
Depending on user settings it's possible to insert a period character (dot) by double-tapping the space bar. This is very nice. After the period it also insert a space proper, making ready for next word.
However, some times I'd like (the same function) instead to close a bracket. 
See the use in the above sentence. I have in my mind double-tapped to get the ) and then later on for the ending period. 
It's easy to implement this. Just make a priority list and do accordingly. In my suggestion, all closing of any left bracket type has priority to inserting a period. 
I'd like to close these type of parenthesis: [ ], ( ), { }, < >.
Easy with virtually no side effect! Most brackets a user doesn't want to close before a period. Of course, it is possible to have a dot inside a parenthesis. Either make a small select box to select the right bracket or the dot, or make an exception for email addresses or url.
This may of course be configurable, as en extra option in addition to the dot insertion.
How about also including other block defining characters, like quotation marks
Reported to http://www.apple.com/feedback/iphone.html 
14 - 4.0 GB not sent and 4.0 GB not received
iOS 4.2.1 8C148 on a 3G iPhone
My iPhone told me I had sent and received 4.0 GB ("Mobilnettverksdata: Sendt 4.0 GB, Mottatt 4.0 GB" in Norwegian):

Having heard about iPhone users with too large bills, I immediately logged into My Account at Network Norway. I had in sum used less than 50 MB (0.05 GB). I have now learnt that if iPhone shows 4.0 GB in both directions, it is probably wrong. But what it it shows other figures?
This was the first time after a couple of years. I cleared the statistics, as I have done every 20th. And it's not run wild yet
Reported to http://www.apple.com/feedback/iphone.html
13 - MMS settings changed all by itself!
iOS 4.2.1 8C148 on a 3G iPhone
All of a sudden my mobile data settings had been changed! I usually have Network Norway with this set up. All of a it pointed to TIM, a subsidary of Telecom Italia!
It is true, my wife and I were in Italy this summer, and TIM came up as an operator then. But that's 8 months ago! And it does not explain this!
I have changed synching iTunes machine lately (from iBook Tiger to Mac Mini Snow Leopard), but it points to the same network disk. See figure on my Blog 019
Observe that "all the time" I have had this iPhone, the Mobile Data settings have been volatile, but they have changed to all empty - see chapter #3 below. So, I am used to typing in all the settings, if one could ever get used to that sort. I think it may be after synchs, but I know it's also after restarts, that I've had to retype. (I have a Picture folder called iPhone with screen shots from the correct settings. Nice to have.)
But this time: I have no idea, and have decided not to speculate, just to be open for comments from any one of the below - or from you! 
I have reported this to Network Norway (mail), TIM (Olivetti, mail) and Apple (http://www.apple.com/feedback/iphone.html). 
Responses
Network Norway: "We know that settings may change when one has been abroad with iPhone. If you have got new settings, and a field is non-blank, it is often because the operator abroad has sent new settings to your phone. However, in the cases where we have seen this, the mobile user has usually been queried for approval." (translated by me) My comments: I have not been queried, and it's 8 months ago and I think the response quite vague. However, I did learn that an operator may update my settings.
Search words in Norwegian 
iPhone Instillinger / Nettverk / Mobildatanettverk (Mobildata) MMS forandret av seg sjøl! 
12 - iPhone screen canals?
According to Wikipedia [1] "waterway canals are navigable transportation canals used for passage of goods and people, often connected to existing lakes, rivers, or oceans."
An "iPhone canal is a navigable icon transportation canal used for passage and short stop of icons, often connected to existing screens or passing through them". This is my suggestion of a definition of one such.
I'd like to have it!
The figure shows my page 1 at three stages. I have a hand made canal there. It's the open unused space. To illustrate I have filled up my page 2 fully. Usually all my screens have a canal. Let me try to transport the iPod icon (1.2). When it's out of the way, the screen reorders (1.3) - the "Instillinger" ("Settings") fills up the vacant place. I like this, no empty space, shuffle into sequence is the rule. All black space is left at the end.
The problem comes when I want to take iPod past page 2 to page 3. Page 2 is continuously being reshuffled. No, not really: if I keep on pushing to the right, on page 2 it would discover that I want to move on to page 3 before if starts to reshuffle page 2. This is grand design!
However, it's not obvious. And, I cannot take a pause and stop at page 2. It then would spill over to page 3 the last icon. Of course, it would not know that I just took a break.
What I would like is that the next screen would shrink and align to top so that I get a black channel beneath. Should I stop, my icon on its way would just sit in the channel. Should I continue? Yes, I grab it again and push to screen 3. Screen two is normalised on its way out of the visible area.
When I am finished I push the icon up into the shrinked screen, the canal is pushed down and out, and the screen scales to standard wiggling icons and does the spillover if it's necessary.
Another great thing about this is that reshuffling would not happen before I ask it to.
Even when I start to move, that screen would open a canal for me. Fine!
Reported to http://www.apple.com/feedback/iphone.html on Nov. 21st 2009.
[1] - Wiki on "Canal": http://en.wikipedia.org/wiki/Canal
11 - iPhone disabling cellular internet access - button missing (closed)

Thanks, Apple! Fixed on version iOS 4! But I've kept the legacy text:
At the moment, the only way I know of how to disable cellular internet access - to save me from a catastrophic bill when I go abroad with my iPhone - is to set the mobile data network APN name wrong.
My provider tells me to set APN to "internet" (fancy name..). That's OK in Norway, where I can afford the data megabytes. But even moving myself into neighbour Sweden makes the megabyte rate n-fold, in other word: prohibitive. (The reason for this is that the providers milk the abroad market here, and there is not yet any regulatory mechanism to stop them. Also, we're in the pre-competitive market phase, it's simply too early. The iPhone, which has made us want to surf, also when abroad, just hasn't been around long enough yet. And not enough regulators seem to have an iPhone..)

So, abroad I set APN to "internet not in use" - which is a perfectly wrong APN name - and when I get back home again I reset to "internet".

I certainly appreciate the minimalistic iPhone user interface, but this solution does not help me! What about a button somewhere? (3.1.2, 7D11, open)

Reported to http://www.apple.com/feedback/iphone.html on Oct. 17th 2009.
10 - Moving iPhone backup files to/from a network disk - Or: how to restore iPhone from another machine (closed)
When I had to do a synch of my iPhone from the first floor machine connected to the network disk instead of the ground floor machine (which I usually use), I got a problem. I needed to take a complete restore of a previously stored backup file. 
Standard synching with iTunes seems to be ok, even if you have to be aware of calendars and address book (and maybe other things which belongs to a machine). Blog 3 gives a flavour of the iTunes network disk world [1].
However, even if the iTunes data base is on the network disk, the iPhone backups are not. They reside locally in your Mac home folder /Library/Application Support/MobileSync/Backup [2].
When I needed to restore from an earlier backup, I moved all the directories there (with names like 5390181f63c8d9bd90bfb99e893792f48cebef08-20090802-114557) from the ground floor machine to the network disk. Good to have for backup of the backup! Then I moved them, or the one I wanted, to the first floor machine.
Perfect, now they were visible in the iTunes' - Preferences - Units on the first floor machine (bare with me if you cannot find things by my names, I have translated the menus from Norwegian). So, now I could "restore without backup" (using the just moved "backup" file!) also on the first floor machine. 
It looks to me that "without backup" means "without your backup" or "with iPhone backup of operating system and associated files only". 
A warning: Restoring Without Backup is a Serious Thing (it's meant to be - restore and backup are separate things - as is synchronizing). If you want newer Notes notes to survive, copy them first with PhoneView; (or similar, search here) and restore them afterwards. And, data that are local to AppStore applications would not survive - you did choose to restore without backup! So, if you restored with no backup, then no backup of those things will appear. So, the lists you had in Todo will reside somewhere in another backup. But afterwards, you may synch again with your present music, movies, pictures etc. 
Still, it's not that servious to restore without backup! You could restore with backup of an earlier version and do screen cuts and save to the notes, or (if it's 3.0 or newer), cut and paste data from the applications and send offas mail or paste in a note (ref. PhoneView). Just find a way to store if (be it pen &amp; paper if you must!) Then you could restore without backup and paste things in again more or less by hand. So, the name you had put in there isn't as losta s you thought. It was recoverable, as long as you have a backup - which iTunes does for you when it wants!
Still, I think that restoring without backup is advocated too often. At least, it's my experience. Do try to avoid it! 
I am afraid that parts of this chapter may be vague or confusing. Whenever I know better, I might try to do a rewrite. 
[1] - 003 - Shared iTunes library on a network disk
9 - Sending mail via GSM server when home's wifi is out of reach - (closed)
After receiving my "swap" iPhone (point 4 here), I goofed the SMTP outgoing list, even if I had saved the setup (point 8 here) screens!
Earlier, the iPhone switched to GSM mail when I left home's safe wifi network. Now I got a response saying that the mail server did not like the address I sent to. But it was my own.
When I called my GSM mobile provider, they said that I did not need the user name and password. They were almost right, because when I switched off the primary SMTP server (most often used from home), sending mail did work. But enabling the primary server again, it failed.
To make a long story short: when I included user name and password for both primary and secondary SMTP servers (even if they individually did not seem to require this), then the failure of the primary's attempt did not stop the process - but went on to try the secondary as well - for success. (This is how I "read" the behaviour.) (3.0.1, 7A400, closed)
8 - Cannot delete SMTP server(s) (closed)
The list of my outgoing mail SMTP [1] servers had added up - and for some days I could not figure out how to delete the unnecessary entries. I only needed my wireless SMTP server as the primary, and my GSM or mobile provider as the only secondary.

However, while fiddling around (during point 9, above), the primary server appeared three times, just between primary and secondary! And when I opened them, they were grayed out. Trying to disable them, they looked enabled again - even if they weren't.
So, how did I clean the list? Here is a recipe that worked for me (inspired by [2]):
First, take a back-up of your settings. The easiest right there may be to take screen snapshots of all the correct SMTP settings. And if you need to note on the pictures, install Sketches from AppStore. (Then, when you synchronize pictures, upload these to the laptop camera upload directory and make a new iPhone pictures directory called iPhone, and move the configuration screen shots to that directory. You'll regret it so little that you will expand to several other set-ups. (You take screen shots by pressing the middle and the off button simultaneously.))
Then, back to the ugly SMTP list. Open the primary, or any one that you are allowed to edit, i.e. not grayed out. Presumably you should try with the entries you want to remove. If the red "Delete server" button is not there, empty the host name field, go up one menu level and open it again. Then the iPhone realises that an SMT server with no name is deletable, and the delete button should appear. Use it. (I had noticed before that the iPhone uses this behaviour: you'll have to make a field empty, then a branch in the menu tree happens - with new buttons arriving.)
Repeat this procedure until you're done. Then add the SMTP server(s) that you had to delete but really wanted to keep - since there is no way to slide table entries up and down. As I said, this certainly worked for me. (3.0.1, 7A400, closed)
[1] - SMTP server: http://en.wikipedia.org/wiki/SMTP_server
[2] - http://discussions.apple.com/thread.jspa?threadID=1711342 - see esullender 30. Jan. 09
7 - iPod / iPhone disappeared from machine (iBook) (not really closed)
When I needed to synch my new "swap iPhone" (note 4 here), my Tiger PPC iBook had decided not to see it! It was not seen by any application, be it iTunes, iPhoto, Image Capture or PhoneView. The iPod also was lost!
However, I noticed in System Profiler [1] that the iPhone was seen by the lower layer USB driver. I observed that it was misplaced on some occasions, and I even could find a configuration where it was not seen. I don't exactly remember how, but I did a mix of the two iBook USB connectors and a hub, with the hub, an external mouse and the iPhone in combinations. Cabling around and updating the display gave me some scenarios. I imagined: there must be some invalid USB descriptors(?) in there! But I had tried several times to restart the machine.
I was pressed. Even if the Intel Mac Mini worked, I did nat want to use it for iPhone work. And the PPC Lamp Mac worked, but with USB 1.0 it took too long. I needed the iBook up! Observe that iTunes with a network disk has been described in post 3.
I thought that maybe the operating system would clean the USB table if I restarted the machine with the iPhone connected! I did, and the soothing beep from the iPhone came twice during power up! And the rest... is just bliss! All is fine now!
I don't know why this happened. I had done Security Updates 2009-003 and 2009-004 on the iBook Tiger PPC in the meantime. But I have no reason to believe that this could be the cause. Or maybe I had plugged the iPhone into the unpowered USB hub [2]? There certainly must have been some reason?!
Update 22June2010: This problem is still persistenet with iPhone 3G with 3.1.3 and iTunes 9.2 (61) running on iBook with Tiger Mac OS X 10.4.11 (8S165). Same solution as above, though!
Update 1April2010: iPhone picture upload from Camera Roll failed to start Image Capture. All of a sudden this happened, the iPhones were visible in iTunes and iPhoto, but even after all combinations of plug, unplug, restart etc,. the Camera Roll (3.0.3 (333) Mac OS X Tiger 1.4.11) did not start. My fix was to start PhoneView (2.3.2) and copy the pictures over manually, and then delete the whole DCIM camera folder, including sub-folders .MISC and 110APPLE. On my iPhone, several other sub-folders 111APPLE up to 120APPLE had appeared. Some contained pictures, some not, but all pictures were visible in Camera Roll. On my wife's there were only the two sub-directories. For both iPhones, PhoneView helped. After I had deleted the directories, I stopped PhoneView and unplugged the iPhone. Then I  filled a picture into Camera Roll and plugged the iPhone in again to find that Image Capture started again! (Filed 1April10, but it's no hoax!) (iPhone 3G and 3GS 3.1.3 (7E18))
Filed to http://www.apple.com/feedback/iphone.html
[1] - Mac OS X System Profiler: en.wikipedia.org
[2] - In Troubleshooting and Maintenance - iPhone: The Missing Manual by David Pogue: http://oreilly.com/iphone/excerpts/iphone-themissingmanual/iphone-troubleshoot-maintenance.html - chapter "Doesn't Show Up in iTunes" it reads "don't plug it into an unpowered USB hub."
6 - Setting light intensity (comment)
I wish setting the iPhone light intensity would be faster. I wouldn't mind if the last screen, with the slider and the Auto switch was gone. Here is a naïve suggestion, where it's controlled in the Settings screen directly:
Fig. - (Norwegian: Instillinger/Settings, Lysstyrke/Light Intensity)
Of course Apple has thought about this. They don't want the graphical and functional overload of this suggestion, or anything similar. But maybe they would be able to handle the text in different languages (lengths) better than above? And the extra Auto button of the last screen - here, with no text, or some pop-up - combined in the slider, where my suggestion is to push it down and then slide it in lower position.
In some AppStore apps one just slide the finger up and down on the screen to get it lighter and darker. But if the SDK API allows a user to do this, then Apple can't (or will not) take it over as a system wide command? (Comment to 3.0)
Filed to http://www.apple.com/feedback/iphone.html
5 - Could not connect to any operator - had to remove and insert SIM card (open)
After I had an incoming call perfectly fine, coming home I sent an SMS. But it failed! The exclamation mark was shown. A resend did not help. I tried to call, but failed. Initially with no warning, but down in this procedure - with a warning. I could not be called. I had no Phone, just the i.
I looked at the service providers, they were three. The list looked correct. One of them was my wife's provider, which worked for her. We tested it. The Auto mode did not connect to any, and the forced mode seemed like it would connect, but it did not.
I switched the telephone completely off and on: no help. Then I switched off, took out the SIM card, inserted it again and switched the iPhone on. Worked!
Now I'll carry the supplied SIM card removal pin in my wallet.

I don't know to which degree any mobile could exhibit this behaviour from time to time. The program base from which the code is taken, and the degree of control when gluing that sw and some new together - for that particular phone, would probably never yield a 100.000% stable product. Now I am uncertain as to which side of the decimal point my phone is. However, hoping for updates does help.

Disclaimer: I do not know if, by coincidence, my service provider was down for that very period. That probability is very low. (3.0, 7A341 no fix yet - point 4 (below)-not done yet)
4 - Cannot connect to network "somename" (closed - was hw)
My iPhone just got unwilling to connect to any wifi (wi-fi) network - even if it displayed the list of possible networks perfectly fine. This most probably is a hardware failure, so it will be returned for repair. The Apple reseller agreed. My guess, as an old hw engineer, is that it's the wifi sender that waved goodbye.
I searched in the Apple support pages and on the net to try to get some tips. So, I reset the network settings in the iPhone, restored the iPhone from iTunes (both with and without backup (bear in mind that data belonging to your AppStore are not any "restored", but reappear on your next synchronization - provided you have a backup.)) - but nothing helped. Switched airplane mode on and of. Removed wifi password and tried different wifi locations that I knew had worked a few days earlier - it still could not connect. Beware, I always keep my iPhone in protective silicone and am careful with it.
I have a feeling that bluetooth also has died, but since I normally don't use it, I am not certain if the connecting problems there are finger trouble. (My iPhone serial number 85838VNMY7H, model MB046LL)
Result: I got a new "swap iPhone" back from service. (It's serial number 5K9276D6Y7H, model MB489B). Observe it's a new model number as well. It now works!
I delivered it to Eplehuset here in Trondheim on a Monday (in August 2009) at 12, it was received by Moobi in Oslo on Thursday at 17 (3 nights!), and the new was sent on Wednesday the week after and arrived here on Thursday (1 night!). That's about 11 days (*). I should have, but was not able to track what happended on Moobi's service page (it was not updated even if I received an SMS telling me it should be). I called Moobi on the phone and received both very supportive responses and one who said he definitively was not allowed to answer me (it should go through Eplehuset, he said, which would have been void, because when I asked them they told me to call Moobi). I called back and hit a different person.
(*) 11 days, when Eplehuset could have swapped the phone over the service department's counter while I waited, or delivered it 1 day after! However, my wife's old 1999 Nokia surviving in a box saved me those days, since my 2004 Sony Ericsson (in the same box) did not like my iPhone SIM-card.
(Norwegian phrases: feil på iPhone, repare, reparert, fikset, wifi sender funket ikke)
3 - Mobile data network settings partly lost (open)
Some times the mobile data network settings disappear, so I have to reenter. This also goes for the MMS settings. I have learnt it now, it's only three easy lines of text, but it's irritating. However, in case I forget, all the settings have been screen clipped and synched and moved into an iPhone picture album. So it's always with me! (3.0, 7A341 no fix yet)
2 - Audio memo with "zero size" plays (open)
I did some recordings the other day. In the list of memos, some display as length 0 (zero, null) seconds. But they play correctly, and the time progress line shows correct length. In PhoneView (point 1, below), size comes out as "unknown". (3.0, 7A341, no fix yet)
See http://discussions.apple.com/thread.jspa?threadID=2086056&amp;tstart=0
1 - "Empty" Camera Roll (closed Mac/Windows users, open for Apple!)
Right now the Camera Roll tabular view (with pictures in a table) looks empty! However, the count of pictures and the single thumb, in the list of all albums is right. And all pictures upload correctly - so that I may see them for the first time. So, I have a film type camera at the moment (not 100% true, though: shooting pictures very fast may help..). This all happened after - you tell me? See http://discussions.apple.com/thread.jspa?messageID=9850890#9850890
(3.0, 7A341, closed for me, open for Apple!)
Apple could have saved us iPhone users of this unnecessary frustration. The iPhone operating system could have discovered that the user "has put a picture into Camera Roll, but it displays none ..oops ..rebuild contents database (xml file?)". But then, in the first place, why does the operating system allow a program to corrupt a (database) file?
Reported to http://www.apple.com/feedback/iphone.html 
Fix (Mac) 
I discovered several places where this has been discussed over the years, a notable one being [1]. But I stopped at http://www.zeldman.com/2007/11/11/iphone-camera-bug/, Jeffrey Zeldman's blog. There, "Ben said on 24 June 2009 at 4:48 pm" (search for that text) pointed to the solution. There, Ben points us to PhoneView at http://www.ecamm.com/mac/phoneview/ by Ecamm Network. I downloaded the free trial version and did Settings, Show Entire Disk. I did like Ben had suggested and deleted the /Disc/DCIM/ folder on my connected iPhone. This is the same exercise that Finder allows me doing on any other camera (and I seem to remember that the iPhone's camera has been visible in Finder earlier?)
Now, Camera Roll again works as expected, it's empty and ready to be filled again!
Ooops... I experienced a problem with PhoneView, where it did not read Notes files etc.. I don't know if it in that situation would have failed to delete /DCIM. However, Ecamm sent me a procedure to rectify: quit PhoneView and clear its preference file at Home/Library/Preferences/com.ecamm.PhoneView.plist. Then do an iPhone/iTunes sync, and restart PhoneView. I have not verified this procedure, but post me if this helped get Camera Roll on the air again 2nd attempt.
Fix (Windows)
Ecamm Network (above) recommends TouchCopy for Windows users (see http://www.wideanglesoftware.com/touchcopy/). NeoDoc has confirmed that TouchCopy has directory delete functionality, and that - with the iPhone directory /DCIM gone - it works. But do remember to load the pictures to the PC first! Thanks, NeoDoc!
(Norwegian search tags: "problemer med iPhone, feil, virker ikke")
.

If you want to comment, please refer to section numbers!
.
.

Sunday, July 12, 2009

013 - Overview

10May2021: Moved to https://www.teigfam.net/oyvind/home/older-blog-notes/

Friday, July 3, 2009

012 - Wishes for a folding editor (2)

This blog has been moved to http://www.teigfam.net/oyvind/home/technology/060-wishes-for-a-folding-editor/ in January 2013.

That page also includes how to run winf32 on Apple OSX on the free WineApp (Wine) emulator, using free X11 (XQuartz), rendering Parallels and Windows not necessary (added january 2013)

Tuesday, April 7, 2009

011 - When is my mail really outgoing?

I would like to know about outgoing mail

I have this interesting case that when I am a visitor I am not allowed to send outgoing mail with my mail client (Mac OS X Mail 2.1.3), but I am with my iPhone (any version, including 3.1.2 October 2009). Both, over the local wireless network at the places we visit.

Disclaimer: sending and receiving mail with a net browser it not the theme of this post. That always works, from any location. I guess - since I am a known user.

Also, if I try sending mail from an iPod under these circumstances, I am neither allowed. With same mail set-up as the iPhone (iPod any version, including 3.1.2 October 2009).

At home

There, the outgoing mail server is smtp.online.no. All users of the wireless which uses that server with my name and password could set up their clients to send in my name. All machines on the net, including iPhone.

Visiting

The network at a friend we often see has smtp.bostream.nu as outgoing mail server. Since I want to send as myself, I have not asked for the friend's log-in details. So, Mail "refuses" me do send over that server, and trying to use the same set-up as at home it refuses me to send over smtp.online.no. I guess it's because the latter server knows the ip address or network provider I use, and then it knows who is sending: it's me, at home, I have paid for the connection: all is well. So, it's not Mail that "refuses", it merely reflects the outgoing mail servers' responses.

My queries

But why am I allowed to send via the visiting wireless from my iPhone (and neither iPod nor Mail)?

Observe that I have told the iPhone not to use the telephone connection by giving it a rubbish APN name - and configured the iPhone so that the telephone provider's server is second to the wifi server. I can see on the mail I this way am able to send from the iPhone that it's routed from bostream's dsl.bredbandsbolaget.se directly to my mail address's incoming server at start.no. My iPhone telephone provider does not seem to be in the expanded mail heading anywhere.

What are the (protocol) mechanisms?

Apple support discussion



Wednesday, March 18, 2009

010 - A running Promela model

Why does this code run and don't deadlock?

mtype = {M_UP, M_DW};

#define LEN 0

chan Chan_data_down = [LEN] of {mtype};
chan Chan_data_up   = [LEN] of {mtype};

proctype P1 (chan Chan_data_in, Chan_data_out)
{
    do
    ::  Chan_data_in  ? M_UP -> skip;
    ::  Chan_data_out ! M_DW -> skip;
    od;
};
proctype P2 (chan Chan_data_in, Chan_data_out)
{
    do
    ::  Chan_data_in  ? M_DW -> skip;
    ::  Chan_data_out ! M_UP -> skip;
    od;
};

init
{
    atomic
    {
        run P1 (Chan_data_down, Chan_data_up);
        run P2 (Chan_data_up,   Chan_data_down);
    }
}


Sunday, March 15, 2009

009 - The "knock-come" deadlock free pattern

Intro and disclaimer

This note is based on a published paper [1]. At the time of publication (2005) I did not think that chapter 10 would describe any more than an interesting case of software engineering. To this date it stays so. However, people have asked me about this pattern. This note therefore describes nothing new, but will add some more discussion.

Disclaimers: 1.) Should anybody claim this pattern as already used, invented or even patented, prior to 2005 - good! It is not known to me (but now I do know that I am not alone, see bullet list below). Please mail me if this is the case - so that I may be abe to honour it here - or obsolete - at least the suggested name. 2.) Even if the pattern is deadlock free, there may be errors in this note. 3.) Any usage of this pattern is out of my control and responsibility.
  • In Jan.10 I discovered that the "USL Distributed Event Driven Protocol" seems to be similar. See [4].
  • In Feb.10 I was made aware that the OpenComRTOS also uses a mechanism in the same street. See [5].
I have named the pattern "knock-come" for a rather obvious reason - the explicit behaviour it must display in order to function properly. The name does not fully describe the behaviour, but it should hold as a reminder.

Rationale

When two software threads or rather, processes, need to talk with each other at the same time, we would get a deadlock if they were communicating over synchronous, blocking channels. This note describes a simple software pattern that removes the possibility of deadlock. It also shows a formal model and verification of the algorithm, written in Promela and evaluated with Spin [2].

The original description, from [1] - of the "knock-come" pattern:
10. Deadlock avoidance
Where two processes spontaneously need to send data to each other, a blocking communication scheme might cause deadlock. This is a state where processes try to communicate – in a circular pattern – blocking for each other to become ready, and therefore unable to proceed. This is pathological and must not happen. All processes run at the same priority, so any priority inversion problem is ruled out in the system.
Figure at http://www.teigfam.net/oyvind/pub/ercim05_at_euromicro-2005/Figure_chapter_10.jpg from [1]. 

The pattern we chose to avoid this was to give the processes clear roles: slave and master. Master may send on the blocking channel any time (solid arrows) when it has something. Slave would never block on any spontaneous message, since the asynchronous “poll me” message (stippled arrow) lets the slave go on and not block, and then instead hang in an INPUT or ALT on the input channel. When the “OK, come on” message arrives from the master, the agreed upon protocol assures no deadly embrace.
Software architecture


Figure at http://www.teigfam.net/oyvind/pub/CPA2006/presentation/Fig1.jpg, from [3].

We see two processes, the top and bottom P_.. processes. The left dotted lines, downwards are asynchronous non-blocking send channels. One one of them is of interest now. Let's call it the knock channel (Chan_202 in the figure). It carries no data.

The other arrows are one up-going come channel (Chan_201) and the down-going channel (Chan_200). Both are synchronous non buffered and blocking send and receive. Both carry data, together with a tag that describes the contents. They are drawn like a two-way channel, but they are two one-way channels. In addition to the come message, these channels are also used to send the actual data - in both directions.

Message sequence in words

Whenever the bottom process needs to send data, it may do it any time. It is the master.

Whenever the top process, the slave, needs to send data, it may send one only query ("knock") any time. For the 1.) data up and the 2.) query - not to deadlock, the query is sent as a no data "interrupt" signal. The slave would send only once per session, so P1_Slave will always proceed (and not block) on this sending.

Whenever the bottom process decides that it has time to handle the query, it sooner or later sends the "ok, come on" up and immediately waits for the slave to respond to that message by sending the data down. Whenever the data has left slave, the sequence with the query may be repeated.

By sooner or later we mean that in the meantime the master may send any number of messages up. As we started with saying, the master may send any time.

The reason why the knock /query / interrupt channel has no data, is really that is simply that it does not need to have any data. Also, in real life, it is simple to implement an asynch channel with zero buffer.

Formal proof of deadlock freedom

The Promela model code below verifies to no "invalid end state", using spin / xspin. This means that it will not deadlock. Observe that with LEN set to zero it will deadlock. It has been modeled to resemble how the processes are coded with a standard synchronous methodology (language or library) - where only inputs may be ALT'ed over. (Note 010 above gives a very interesting deadlock free alternative.)

The code is my initial iteration on the theme:

mtype =
{
    M_KNOCK_DIRDOWN,
    M_COME_DIRUP,
    M_DATA_DIRUP,
    M_DATA_DIRDOWN
};

#define LEN 1 /* Invalid end state (ie deadlock) if this is zero */

chan Chan_knock_down = [LEN] of {mtype}; /* Chan_202 */
chan Chan_data_down  = [0]   of {mtype}; /* Chan_200 */
chan Chan_data_up    = [0]   of {mtype}; /* Chan_201 */

proctype P1_Slave (chan Chan_knock_out, Chan_data_in, Chan_data_out)
{
    bool Knock_send;
    bool Knock_sent = false; /* necessary? */

    Run:
        if
        ::  Knock_send = true;  /* non-deterministic setting to true.. */
        ::  Knock_send = false; /* ..or false */
        fi;

        if
        ::  (Knock_sent == false) && (Knock_send == true) ->

            /* Am slave, but want to get rid of my data now */
            Chan_knock_out ! M_KNOCK_DIRDOWN;
            Knock_sent = true;

        ::  else -> skip;
        fi;

        if
        ::  Chan_data_in ? M_DATA_DIRUP -> skip;

            /* Am slave, always able to receive from master */

        ::  Chan_data_in ? M_COME_DIRUP ->

            /* Got "come" from master, do it */
            Chan_data_out ! M_DATA_DIRDOWN;
            Knock_sent = false; 
        fi;
        goto Run;
};

proctype P2_Master (chan Chan_knock_in, Chan_data_in, Chan_data_out)
{
    bool Knock_received = false;
    bool Data_send;

    Run:
        if
        ::  Data_send = true;  /* non-deterministic setting to true.. */
        ::  Data_send = false; /* ..or false */
        fi;

        if
        ::  (Data_send == true) ->

            /* Is master, may always send */
            Chan_data_out ! M_DATA_DIRUP;

        ::  (Knock_received == true) ->

            /* Send "come" and get data, according to "contract" */
            Knock_received = false;
            Chan_data_out  ! M_COME_DIRUP;
            Chan_data_in   ? M_DATA_DIRDOWN;

        ::  else -> skip;
        fi;

        if
        ::  Chan_knock_in ? M_KNOCK_DIRDOWN ->
            /* Slave "knocks" */
            Knock_received = true;

        ::  timeout -> skip;
            /* global "else" to make "Chan_knock_in" input a poll */
        fi;
        goto Run;
};

init
{
    atomic
    {
        run P1_Slave  (Chan_knock_down, Chan_data_up,   Chan_data_down);
        run P2_Master (Chan_knock_down, Chan_data_down, Chan_data_up);
    }
}

Daisy-chaining this pattern

This pattern scales. You may take a slave's Chan_data_down and connect to another's Chan_data_up, and let a new master have one more Chan_knock_down from each new slave. This daisy-chains with loop-back, equal slaves, which must then share via-traffic for the others. I have proven it deadlock free with a slightly modifed Promela model.

References

[1] - From message queue to ready queue. Øyvind Teig, 2005. Subtitle: Case study of a small, dependable synchronous blocking channels API. "Ship & forget rather than send & forget". Ref chapter "10 - Deadlock avoidance". See http://www.teigfam.net/oyvind/pub/pub_details.html#Ercim05 and read at http://www.teigfam.net/oyvind/pub/ercim05_at_euromicro-2005/paper.pdf. In First ERCIM Workshop on Software-Intensive Dependable Embedded systems. Editors: Amund Skavhaug, Erwin Schoitsch. ISBN 2-912335-15-9, IEEE Computer press

[2] - Promela and Spin. See http://spinroot.com/ and http://en.wikipedia.org/wiki/Promela

[3] - No Blocking on Yesterday’s Embedded CSP Implementation. Øyvind Teig. Subtitle: The Rubber Band of Getting it Right and Simple. In Communicating Process Architectures 2006, Peter Welch, Jon Kerridge, and Fred Barnes (Eds.) IOS Press, 2006, pages 331-338, ISBN 1-58603-671-8. Read at http://www.teigfam.net/oyvind/pub/pub_details.html#NoBlocking

[4] - "USL Distributed Event Driven Protocol", described in Universal Systems Language: Lessons Learned from Apollo. Margaret H. Hamilton and William R. Hackler, Hamilton Technologies, Inc. In IEEE Computer, Dec. 2008 pp. 34-43
("USL"). Also see my 007 - Synchronous and asynchronous, where this is discussed thorouhgly.

[5] - Comment [C.4] of 007 - Synchronous and asynchronous

--

Sunday, March 1, 2009

008 - Safari oblivion - Firefox to the rescue

I did something legal and lost both new and old Safari

Today (March 1st 2009) I downloaded Safari 4.0 beta for Tiger, to run on the iMac G4 (800 MHz) and iBook G4 (1.33 GHz) - both running Tiger 10.4.11 and security update 2009-001.

The conclusion now is that the on both machines, I have no working Safari browser! The beta crashed on both machines, and the old Safari did not work on either - I started Firefox and downloaded Safari 3.2.1 for Tiger to be reinstalled.

The good tip is to have more than one browser installed on your machine! Should the browser you updated fail, you'd have an easy road to the net. (There is ftp on any machine, to download new versions, or you would have more than one machine or friends with machines, and a memory stick..)

Safari.crash.log

See next - Safari discussion group:

This note at Safari discussion group

I have added this note to the Safari discussion group at Apple's site. Some quite good comments there: http://discussions.apple.com/thread.jspa?messageID=9084774&#9084774


Solution

1.) Delete the Safari.app (it's probably a mix of 3.2.1 and 4.0 beta?)
2.) restart the machine
3.) install with Safari3.2.1Ti.pkg (downloaded with Firefox) 
4.) run it for a day, install another browser, then go ahead with Safari 4.0 beta

Cause of problem - and a suggestion for Apple

Prior to installing the 4.0 beta I had moved the original Safari.app to a subdirectory and even renamed it. The Installer got confused - without warning me and do appropriate action - and the unInstaller also got confused (see Apple discussion thread).

Apple should enhance their install software (script) not to err (so fatally for some who would not have an alternative browser) - since it's completely legal to move and rename applications.


Sunday, February 22, 2009

006 - Preferential programming versus me

This post is in work

My goal with this post is to try to position paper [1] and [2] and my own programmer's life, perhaps with the table below. The table may be removed later, right now I will see if it helps me even writing this post.

(un)real disagreement
I prefer Why? ! Why not?
Why not? Why? They don't prefer
Doesn't interest me Why? agreement Why not?
Why not Why? Doesn't interest them
I don't prefer Why? ¡ Why not?
Why not? Why? They prefer
(un)real agreement

References
[1] - Epistemological Pluralism and the Revaluation of the Concrete
Sherry Turkle and Seymour Papert
http://www.papert.org/articles/EpistemologicalPluralism.html
[2] - On the difference between analysis and design, and why it is relevant for the interpretation of models in Model Driven Engineering
Gonzalo Génova, María C. Valiente and Mónica Marrero
http://www.jot.fm/issues/issue_2009_01/column7/
[3] - Epistemology
http://en.wikipedia.org/wiki/Epistemology
...
...

Monday, February 9, 2009

005 - Press '?' for help, press '!' for new idea

This post is a copy of a the initial (27Aug08) version of a note that was first published at the "Designer's Notes" at my home page (press picture on top of this page..).

..or right at http://www.teigfam.net/oyvind/pub/notes/17_Innovating_in_a_window.html

----- copy begin -----

Innovating in a window ("winnovating")

Always present '?' is for help, but why isn't '!' also always there?

Online help systems [1] have been at our fingertips for many years. I remember, back in the early 1990's that we started to use a "help editor" to create a "help" for the Windows systems that we shipped to customers. The systems were clients, doing man-machine communication, with buttons and menues, and nice curves of pressure samples from rotating diesel engines. The embedded data collecting and computing units were mounted in the ships' engine rooms, while the PCs were in the engine control room. And, the intricacies of the system were detailed for the user, available by pressing the ? question mark button. The help was context sensitive, so that one should get the info needed right then. Not more, not less.

Over the years, we have become accustomed to a computer based unit's context sensitive help system, whenever there's knowledge to reach for.

But, how about the opposite? Some new idea or additional information, some small or large innovation we want to jot down, now! The other direction from the help system, so to say, seen by an ! exclamation mark.

Implementing such an exclamation mark would be difficult. It would contain tools, complex logistics and legal matters. At least the suggestion outlined here.

We talk about context sensitive innovation "in a window". Cast in an idea-editor, especially made for the purpose. More that the "send us feedback" menu entry often found.

When we have jotted down the idea, we would need to store it. An idea-server would handle this for us. It would store the idea where it's supposed to. Like, on my local machine.

Or, you may want to send this idea to the maker of the product or anyone who could handle it.

Sending off good ideas right now is a black hole. The recipient could wrap the idea to oblivion. Therefore, we need an idea-agency or idea-bank, a public and safe place where the idea may be posted. The service should be free, since an agency would get neutral money. The people has understood that it's for the best of all, to have an idea-boiling society.

Now, when a user is able to take advantage of the idea, its source is cast in iron. It's me, and it's my idea that's used. For the user of the idea, "not invented here" could become an asset. "Idea! inside" labeled on the product could display this. People would love these products.

And the user would easily find ideas, through some kind of global idea-portal.

The system should be able to inspire any small or big idea. Jot them down, send them, cast them in iron. And idea-sense would collect money for used (and browsed) ideas.

Of course, this would be sitting above the world's patent system (or..below?), like PayPal uses the banking system to make it easier for the payer.

Did I say that the idea-bank should have an idea-server to handle new ideas coming from reading another person's idea? Stored locally at my machine only, or sent externally to the idea-bank.. So, idea-branching should be catered for. Ideas seldom appear in vacuum. Is an idea the most recursive cognitive pattern in the universe?

Humankind certainly needs to come up with some new ideas. We can't afford to waste one of them!

Except some, that would not serve us..

---

This naive set of ideas I have never seen before. I have made a pdf of the original version of this file at 17_Innovation_in_a_window_27Aug08.pdf virtually becoming my safe? idea-bank. Should this not be new, it would certainly be against my knowledge. If so, please mail me. Should my use of words in this note infringe on any trademark etc., rememeber that I use them in a descriptive context only, not pertaining to any such registered use.

This idea is open for use by any. But (disclaimed above): don't think it's your idea! So, give me what's my part of it!

However, it would need much de-naivification!


----- copy end -----


Archive and about

Popular Posts

Øyvind Teig

My photo
Trondheim, Norway

All new blogs and new home page start at
https://www.teigfam.net/oyvind/home

Overview of old blog notes here

My technology blog was at
https://oyvteig.blogspot.com

and my handicraft blog was at
https://oyvteig-2.blogspot.com

PS: just call me "Oyvind"