Osmolarity is distinct from molarity because it measures osmoles of solute particles rather than moles of solute. The distinction arises because some compounds can dissociate in solution, whereas others cannot.
Ionic compounds, such as salts, can dissociate in solution into their constituent ions, so there is not a one-to-one relationship between the molarity and the osmolarity of a solution. For example, sodium chloride (NaCl) dissociates into Na and Cl ions. Thus, for every 1 mole of NaCl in solution, there are 2 osmoles of solute particles (i.e., a 1 mol/L NaCl solution is a 2 osmol/L NaCl solution). Both sodium and chloride ions affect the osmotic pressure of the solution.
Another example is magnesium chloride (MgCl), which dissociates into Mg and 2Cl ions. For every 1 mole of MgCl in the solution, there are 3 osmoles of solute particles.
Nonionic compounds do not dissociate, and form only 1 osmole of solute per 1 mole of solute. For example, a 1 mol/L solution of glucose is 1 osmol/L.
Multiple compounds may contribute to the osmolarity of a solution. For example, a 3 Osm solution might consist of: 3 moles glucose, or 1.5 moles NaCl, or 1 mole glucose + 1 mole NaCl, or 2 moles glucose + 0.5 mole NaCl, or any other such combination.