Ejemplo n.º 1
0
void Main ()
{
    int yieldID;
    if ((yieldID=Fork ()) == 0) {
        if (Fork () == 0) {
            Yield (yieldID);
            /* Process 4 */
            SlowPrintf (7, "444444444444444444");
            Exit ();
        }
        /* Process 2 */
        Yield(1);
        SlowPrintf (7, "222222222222222222");
        Exit ();
    }
 
    if ((yieldID = Fork ()) == 0) {
        /* Process 3 */
        Yield(1);
        Yield (2);
        SlowPrintf (7, "333333333333333333");
        Exit ();
    }
 
    /* Process 1 */
    Yield (yieldID);
    SlowPrintf (7, "111111111111111111");
    Exit ();
}
Ejemplo n.º 2
0
void Main ()
{
	if (Fork () == 0) {

		SlowPrintf (7, "2222222222");		/* process 2 */
		Exit ();
	}

	if (Fork () == 0) {

		SlowPrintf (7, "3333333333");		/* process 3 */
		Exit ();
	}

	SlowPrintf (7, "1111111111");			/* process 1 */
	Exit ();
}
Ejemplo n.º 3
0
void Main ()
{
	if (Fork () == 0) {

		if (Fork () == 0) {

			if (Fork () == 0) {

				if (Fork () == 0) {

					if (Fork () == 0) {

						if (Fork () == 0) {

							if (Fork () == 0) {

								if (Fork () == 0) {

									if (Fork () == 0) {

										if (Fork () == 0) {

											if (Fork () == 0) {

												SlowPrintf (5, "13 13");	/* process 13 */
												Exit ();
											}

											SlowPrintf (5, "12 12");	/* process 12 */
											Exit ();
										}

										SlowPrintf (5, "11 11");	/* process 11 */
										Exit ();
									}

									SlowPrintf (5, "101010");	/* process 10 */
									Exit ();
								}

								SlowPrintf (5, "999");	/* process 9 */
								Exit ();
							}

							SlowPrintf (5, "888");	/* process 8 */
							Exit ();
						}

						SlowPrintf (5, "777");	/* process 7 */
						Exit ();
					}

					SlowPrintf (5, "666");	/* process 6 */
					Exit ();
				}

				SlowPrintf (5, "555");	/* process 5 */
				Exit ();
			}

			SlowPrintf (5, "444");	/* process 4 */
			Exit ();
		}

		SlowPrintf (5, "333");		/* process 2 */
		Exit ();
	}

	// if (Fork () == 0) {

	// 	SlowPrintf (5, "12 12");		/* process 3 */
	// 	Exit ();
	// }
	// if (Fork () == 0) {

	// 	SlowPrintf (5, "11 11");		/* process 3 */
	// 	Exit ();
	// }
	// if (Fork () == 0) {

	// 	SlowPrintf (5, "10 10");		/* process 3 */
	// 	Exit ();
	// }
	// if (Fork () == 0) {

	// 	SlowPrintf (5, "999");		/* process 3 */
	// 	Exit ();
	// }
	// if (Fork () == 0) {

	// 	SlowPrintf (5, "888");		/* process 3 */
	// 	Exit ();
	// }
	// if (Fork () == 0) {

	// 	SlowPrintf (5, "777");		/* process 3 */
	// 	Exit ();
	// }
	// if (Fork () == 0) {

	// 	SlowPrintf (5, "666");		/* process 3 */
	// 	Exit ();
	// }
	// if (Fork () == 0) {

	// 	SlowPrintf (5, "555");		/* process 3 */
	// 	Exit ();
	// }
	// if (Fork () == 0) {

	// 	SlowPrintf (5, "444");		/* process 3 */
	// 	Exit ();
	// }
	// if (Fork () == 0) {

	// 	SlowPrintf (5, "333");		/* process 3 */
	// 	Exit ();
	// }

	if (Fork () == 0) {

		SlowPrintf (5, "222");		/* process 3 */
		Exit ();
	}

	SlowPrintf (5, "111");			/* process 1 */
	Exit ();
}