If you are on a private net/chain you actually don't need to mine to get ethers, but just to confirm transactions.
You can fund your account(s) by specifying the amount in wei you want that account to start with, in your genesis json file:
"alloc": {
"<your account address e.g. 0xaaabd38c8f1a188a0b8bbf93bdca420cfdd760aa>": {
"balance": "10000000000000000000"
}
}
Another thing you can do if you still want to mine to get ethers is lower the difficulty, again in the genesis block, a value of "0x400"
or `"0x200" will let you mine faster the first blocks.
If your geth is stuck and doesn't mine anymore (on osx I found it common when you put the computer in sleep), simply kill it with Crtl-C and restart it.
To specify your genesis block you can pass these parameters to the geth command:
$ geth --genesis <genesis json file path> --datadir <some path to an empty folder>
A sample genesis block is:
{
"nonce": "0x000000000000002a",
"timestamp": "0x0",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"extraData": "0x0",
"gasLimit": "0x8000000",
"difficulty": "0x400",
"mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"coinbase": "0x0000000000000000000000000000000000000000",
"alloc": {
}
}
You can find a more complete guide here
Each account has a number known as the nonce. It starts at zero, and after every processed transaction, it is incremented.
Each transaction also has a nonce. For a transaction to be processed, the account must have exactly the same nonce of the transaction. Not only does this force all transactions to occur in the order sent, but it also prevents a duplicate transaction. If a miner tried to run a transaction again, the block would be invalid, because the nonces would not match.
However, if there are multiple blockchains in play, this protection isn't as strong. An attacker could replay a transaction that occurred on one blockchain on another, since the nonce on the other blockchain would not have been incremented. This was eventually fixed by EIP 155.
Best Answer
The following is a simplified explanation of what geth does.
There are two main places where transactions can be: in a block, or in the transaction pool (txpool).
When a node first hears about a transaction, it puts it in the txpool. These are essentially zero confirmation transactions. There's a number of ways to access this, most particularly the "pending" psuedoblock in web3.
When a node starts to mine, it will take the highest-paying transactions in the txpool, one-by-one, and execute them. When it runs out of the gasLimit or transactions in the pool, it commits to mining that specific block. (This appears in the console as something like "commit new work on block X with Y txs...") It then continues hashing that block until it finds a hash that is sufficiently rare enough for the block to be accepted by the network.
Every other transaction, whether it was received before it started work on the block but could not use it for some reason, or whether it received it afterwards, remains in the txpool until it is mined, or becomes permanently invalid for some other reason.