Unable to understand sentence in the book of operating system - unix

"The events depicted are artificial in that processes do not always experience them, but they illustrate various state transitions."
I am unable to understand the perfect meaning of this sentence. I assume this is because of I am not native English speaker or I don't have much experience about processes and their states. What the above sentence tries to convey? Is it saying that The process which is first time experiencing the state will consider it as artificial or some thing more. Kindly guide me so that I am able to clear what is the meaning of this sentence. Following is the some more information about the line. Following will help you to find the line in book if you want to read the other sentences with this sentences.
Name of the Book: "The Design of the UNIX operating system"
Author : "M.J.Bach"
Chapter : " 6 - The Structure of Processes"
Page number : "147"
Topic : "6.1 - Process states and transitions"
paragraph number : "2 from the beginning of the page"
Line number related to paragraph : "2 line in paragraph."

I don't have my copy of Bach handy at the moment, so I may be a bit off base on what I remember, but I think what it is trying to say is that it may help conceptually to think of a process going from state A to state B and then to state C, but a real-world OS may choose to go directly from A to C and just perform the steps for both transitions at once, because there may not be any real reason to actually have a state B and allow processes to live in that state.

Related

Getting a simple reply from a character in Inform 7

I have a non-player character in an Inform 7 Interactive Fiction story that I would like to get a simple reply from. The character is a robot doctor. When you get on the exam table the robot doctor holds out a tongue depressor and asks you to say, "Ah." I would like the character to say something when the player types, "say ah" but so far it's not working.
Here is my code thus far:
The exam table is a supporter in the Med Bay. It is fixed in place and enterable.
In the Med Bay is a person called Auto-Doc.
After entering the exam table, say "A number of bright lights embedded in an overhead panel bathe you in a cold, white light. A panel in the wall opens and an auto-doc trundles forth on a three-wheeled base. Clutching a tongue depressor in its mechanical grip, a small speaker hidden within crackles with the words 'Say, ah.'"
After speaking in the presence of the Auto-Doc, say "Mmm. Mm-hmm. Very interesting."
The last line is causing the compiler to throw an error, but I am unable to figure out what to use. I've tried Instead of speaking, After telling the Auto-Doc something, After saying ah in the presence of the Auto-Doc, and so far nothing is working.
Any hints as to how I can get the Auto-Doc to say something after the player types "say ah"? I'd even be happy with the Auto-Doc replying the same way no matter what the player says.
Here's a handy tip: command ACTIONS while playing the game in the IDE to see the action name when you type commands.
>actions
Actions listing on.
>say ah
(to Auto-Doc)
[answering Auto-Doc that "ah"]
There is no reply.
[answering Auto-Doc that "ah" - succeeded]
>
So the rule you're looking for is:
Instead of answering Auto-Doc that "ah":
say "Mmm. Mm-hmm. Very interesting."
After some more research, I have discovered that the responses understood by Inform are yes, no, and sorry. So understand "ah" and "say ah" as saying yes. followed by Instead of saying yes in the presence of the Auto-Doc, say "Mmm. Mm-hmm. Very interesting." is one way to do it.
Here's what the code looks like now:
The exam table is a supporter in the Med Bay. It is fixed in place and enterable.
After entering the exam table, say "A number of LEDs embedded in the ceiling switch on, bathing you in a cold, white light. A panel in the wall opens and an auto-doc trundles forth on a three-wheeled base. Clutching a tongue depressor in its mechanical grip, a small speaker hidden within crackles with the words 'Say, ah.'"
In the Med Bay is a person called Auto-Doc.
Instead of saying yes in the presence of the Auto-Doc, say "Mmm. Mm-hmm. Very interesting."
Understand "ah" and "say ah" as saying yes when location is Med Bay.
Instead of saying no in the presence of the Auto-Doc, say "Hmm..."
This sets up two different non-committal responses for saying yes and no. Saying 'ah' is understood as saying yes, so the player gets a response.

DisjointSet in Inform 7

A DisjointSet is a kind of Object.
A DisjointSet is a part of every DisjointSet.
Trying to start a DisjointSet Object in Inform 7, but even though I know it could cause a infinite loop, I want to do it anyway for the obvious reason that it is part of the algorithm.
Here is the error
You wrote 'A DisjointSet is a part of every DisjointSet' : but this
generalisation would be too dangerous, because it would lead to
infinite regress in the assembly process. Sometimes this happens if
you have set up matters with text like 'A container is in every
container.'.
I suppose it would be easier to do something like this in Inform 6, but I don't have any knowledge of it so I am trying to avoid it. But will accept help in Inform 6 too.
Edit following #jeroen-mostert advice:
Maybe I'm doing it wrong, but maybe some sample code might help.
A DisjointSet is a kind of Container.
A DisjointSet always contains a DisjointSet called the Parent.
The First Decl is a DisjointSet.
The Second Decl is a DisjointSet.
The Parent of the First Decl is the Second Decl. [This line doesn't work.]
The sentence 'The Parent of the First Decl is the Second Decl'
appears to say two things are the same - I am reading 'Parent of the
First Decl' and 'Second Decl' as two different things, and therefore
it makes no sense to say that one is the other: it would be like
saying that 'St Peter is St Paul'. It would be all right if the second
thing were the name of a kind, perhaps with properties: for instance
'Pearly Gates is a lighted room' says that something called Pearly
Gates exists and that it is a 'room', which is a kind I know about,
combined with a property called 'lighted' which I also know about.
I'll give two answers. First, the question you asked:
Linked lists in Inform 7
The problem is that contains and is a part of indicate physical concepts. When you use those words, Inform thinks you're talking about matter in the fictional universe, as if you said, "every bucket contains a bucket".
Instead, define your own property that has nothing to do with Inform's physical world model:
Every DisjointSet has a DisjointSet called the Parent.
With this change, your code works.
Now on to the question you didn't ask:
Relations in groups
If what you want is a bunch of sets of objects, where the sets are all disjoint, use an equivalence relation:
Friendship relates people to each other in groups.
This defines a relation called "friendship" that divides all animals into disjoint sets, such that an animal is friends with the other animals in that set, and not friends with any other animal.
Then you must teach Inform a bit of vocabulary:
The verb to be friends with means the friendship relation.
After that, the phrase "X is friends with Y" means that X and Y are in the same friendship set. You can say things like "Now the badger is friends with the giant squid" to update the sets.
See "Relations in groups" in the manual.

Inform7: Working with properties of rooms

I'm very, very new to this language, and wrapping my head around "how to do things with stuff" is proving to be a very frustrating endeavor.
My goal here is to create a mechanic where certain rooms are dangerous, and become more dangerous the longer the player stays in them. If the player stays in a dangerous room for too long, a death scene is triggered.
I've got code that looks like this:
[The "danger rule"]
A room has a number called danger level. The danger level of a room is usually 0.
Definition: A room is dangerous if its danger level is 1 or more.
Definition: A room is deadly if its danger level is 9 or more.
Every turn (this is the increasing danger rule):
If the player is in a dangerous room:
Increase danger level by 1.
Every turn (this is the death by danger rule):
If the room is deadly:
do nothing.[Later...]
Every turn (this is the danger explanation rule):
say danger level.
[further down]
The Feeding Chamber is south of the dungeon."You enter a large, dimly lit room with straw on the floor, surrounded by various cages embedded in the wall.[line break]Blood spatters are all over the floor, and it looks as if there's been a fight recently". After going to the feeding chamber for the first time:
try looking;
say "It smells like grues around here. I would be careful if I were you..";
The Feeding Chamber has danger level 5.
I can't seem to figure out how to properly work with the "danger level of a room". The explanation rule I defined causes a runtime error when entering a dangerous room:
`*** Run-time problem P31: Attempt to use a property of the 'nothing' non-object: property danger level`
..And attempts to re-word the rule to something like the danger level of the room or the danger level of this room lead to perplexing compilation messages such as:
`In the sentence 'say the danger level of the room' , it looks as if you intend 'danger level of the room' to be a property, but 'a room' is not specific enough about who or what the owner is.`
What is the "right" way to reference properties of objects in this way?
The magic words here were "of the location". If we pretend that that this was another programming language for a moment, the way I was writing this was as if I was referring to a class "the room" rather than an instance of the class currently being referenced "the location".
The working rule is as follows:
Every turn while the player is in a dangerous room:
Increase danger level of the location by 1.
The trick is to give Inform enough information to know which particular thing you're referring to. The problematic sentence in the original question is perfectly valid english that a human could parse, but the computer needs a bit more help in determining what room we mean when we say "the room".

Chicken or egg in functions/actors processing WorldState

I have read the series "Purely Functional Retrogames"
http://prog21.dadgum.com/23.html
It discusses some interesting techniques to build a (semi-)pure game world update loop.
However, I have the following side remark, that I cannot seem to get my head around:
Suppose you have a system, where every enemy, and every player are separate actors, or separate pure functions.
Suppose they all get a "WorldState" as input, and output a New WorldState (or, if you're thinking in actor terms, send the new WorldState to the next actor, ending with for instance a "Game Render" actor).
Then, there's two ways to go with this:
Either you start with one actor, (f.i. the player), and feed him the "current world".
Then, you feed the new world, to the next enemy, and so on, until all actors have converted the worlds. Then, the last world is the new world you can feed to the render loop. (or, if you followed the above article, you end up with a list of events that have occurred in the world, which can be processed).
A second way, is to just give all actors the current WorldState at the same time. They generate any changes, which may conflict (for instance, two enemies and the player can take a coin in the same animation frame) -> it is up to the game system to solve these conflicts by processing the events. By processing all events, the Game actor creates the new world, to be used in the next update frame.
I have a feeling I'm just confronted with the exact same "race condition" problem I wished to avoid by using pure functions with immutable data.
Any advice here?
I didn't read the article, but with the coin example you are creating a kind of global variable: you give a copy of the world state to all actors and you suppose that each actor will evaluate the game, take decision and expect that their action will succeed, regardless of the last phase which is the conflict solving. I would not call this a race condition but rather a "blind condition", and yes, this will not work.
I imagine that you came to this solution in order to allow parallelism, not available in solution 1. In my opinion, the problem is about responsibility.
The coin must belong to an actor (a server acting as resource manager) as anything in the application. This actor is the only responsible to decide what will happen to the coin.
All requests (is there something to grab, grab it, drop something...) should be sent to this actor (one actor per cell, or per map, level or any split that make sense for the game).
The way you will manage it is then up to you: serve all requests in the receive order, buffer them until a synchro message comes and make a random decision or priority decision... In any case the server will be able to reply to all actors with success or failure without any risk of race condition since the server process is run (at least in erlang) on a single core and proceed one message at a time.
In addition to Pascal answer, you can solve parallelization by splitting (i assume huge map) to smaller chunks which depend on last state (or part of it, like an edge) of its neighbours. This allows you to distribute this game among many nodes.

Partially re-create Risk-like game based on incomplete log files

I'm trying to re-create this conquerclub (Risk-like) game:
http://conquerclub.barrycarter.info/ONEOFF/7460216.html
In other words, I want to know who owned each territory at each point
in time, and how many troops they had on that territory. My primary
source of information is the Game Log. Notes:
% It's not in the Game Log, but all territories start w/ 3 troops.
% Since we know the territory owners at the end of the game, and the
Game Log mentions all owner changes, determining territory owners at
any point in time is easy.
% The challenge is to find the number of troops on a territory at a
given time.
% The Game Log gives information on troop deployment, reinforcement,
and conquest.
% However, the Game Log is incomplete. Suppose territory X attacks
territory Y unsuccessfully, but both territories lose troops in the
process. The Game Log will not mention this.
% It's probably not possible (in general) to find the exact number
of troops on a territory at a given time, so I'm looking for a range.
% I tried feeding the data to Mathematica as a series of
inequalities, but as the manual warns, the computation time increases
exponentially with the number of inequalities. Even with a fairly
small number of inequalities, it hangs. Plus, I'm not convinced
Mathematica is the right tool here.
% Any thoughts? Another example is:
http://conquerclub.barrycarter.info/ONEOFF/7562013.html
% I know about http://userscripts.org/scripts/show/83035 but that only tracks \
owners, not number of troops.
You could make use of Prolog's constraint programming (specifically, CLP/FD). It would require you to encode all rules in Prolog, which might be a non-trivial task. However Prolog would be able then to show you all possible valid (legal in terms of encoded rules) ways of playing such game, or just show ranges of possible values.
Also, while CLP/FD in Prolog sometimes is quite fast, it might be difficult to use it to make solving your problem quickly. Most free solvers have many quirks.
Again, I think this is a nontrivial task, and even greater if you haven't programmed in Prolog earlier. But I am pretty sure this would give you answers you seek.

Resources