A Multi-threader Hub Example

Listed below is a small sample of a real hub from one of our multi-threaded processes. It shows how each case statement will invoke a thread at the command of the central controlling shell. It also shows how the threads are linked in a giant patch panel that creates the design of the process. Individual threads have no understanding of the overall design.

       case TH_TERMINAL_READER:
                     prompt_and_read ( dynamic_params.display_long_prompt
				     , dynamic_params.scon_input_length
				     , TH_PROMPT_GUARD );
                     break;


       case TH_PROMPT_GUARD:
                    prompt_guard ( -1				/* next CRT    */
				 , TH_TERMINAL_READER		/* Reply Chain */
				 , TH_PROMPT_HANDLER
				 , TH_EMERGENCY_PI
				 , TH_NEW_SPLIT_CHANNEL );
                     break;


       case TH_NEW_SPLIT_CHANNEL:
                    split_stream ( TH_PROMPT_GUARD		/* Reply Chain */
				 , TH_AUTODAT_IN
				 , TH_REPLICATION );
                     break;


       case TH_REPLICATION:
                    replicator ( my_network
			       , my_backup_node
			       , "TH_GHOST_TTY"
			       , TH_PACKET_REPLY );		/* network thread */
                    break;


       case TH_GHOST_TTY:
		    ghost_tty ( TH_AUTODAT_IN );		/* next thread */
		    break;


       case TH_AUTODAT_IN:
                    autodat_in ( TH_AUTODAT_CONTROL
			       , TH_AUTODAT_BASE
			       , TH_NEW_SPLIT_CHANNEL		/* Reply Chain  */
			       , TH_VERTICAL_EDIT );		/* next thread  */
                    break;


       case TH_VERTICAL_EDIT:
                    vertical_editor ( TH_AUTODAT_IN		/* reply chain    */
				    , TH_BLOCK_BIN		/* bin  thread    */
				    , TH_PROMPT_HANDLER		/* prompt thread  */
				    , TH_HORIZONTAL_EDIT 	/* edit thread    */
				    , TH_RAW_COMMAND_HISTORY	/* history thread */
				    ,  UP_KEY
				    ,  DOWN_KEY
                                    , TH_ALT_VERTICAL_EDIT );	/* next thread    */
                    break;

Back to our main page