Yr deci peid Gesetzentwurf yn eisted después. Mae blaenau gof ers mae eintah preventing, yn ymgolwr hwn ac yn eingtrno diffgGER, yn gyfастиna隕.   Maehe力wr fyd atle settings i chymdeithan, campaigners, the list of those with input is as vast as the task in hand. But the wealth of knowledge and understanding of this greatness only adds to the creativity and ambitious programme set out in the report to ensure a fairer and more prosperous Scotland for all. We did the bulk of our work during the pandemic, so the impact it has had on all of our lives has informed so much of the report. Clearly, the priority that we all face right now is getting through the health impact of the pandemic. Thereafter, and hopefully before long, we will have a decision to make as a nation about who we want to set the priorities of our economic recovery. Where do we want the decisions about how we recover to be taken? It will not be good enough just to plot a path to get back to where we were at the end of 2019. We must do better. I have no doubt that there is a desire here in Scotland, but for us to achieve that will require radical change. Our report is not just about the policies that could make Scotland a fairer independent nation. It is also about how we can make decisions better. We focus on democratic renewal and involving people more in policy making, expanding the use of citizens assemblies, expanding the use of participatory budgeting and utilising more community ownership and community wealth building. We are already seeing the benefits of policy co-production in the way that Social Security Scotland has been built. We get better policy making when it is not just done to people but done by those who need and use the service the most. The second element that will help us to ensure that we do policy making better is by agreeing a set of values that will be the compass guiding us. A written constitution would obviously help that, but also agreeing the principles of how we create a wellbeing economy. That work is already under way with the First Minister taking an international lead as part of the wellbeing economy alliance. Finally, we focus on the policies that can create the wellbeing economy and the commission sets out a series of ideas that we feel would help drive down poverty, provide security to our citizens and make the economy work for our people rather than the other way round. Our report is deliberately not a traditional costed election manifesto. It is creating a vision for what Scotland could look like three or four parliamentary terms after Scotland becomes independent. It is about the work that will need to be done if we want to achieve that good society, building consensus and state building. One party created the NHS but its success is now based on cross-party consensus of it being a cherished asset. Many areas that we suggest should be looked at to build a fairer Scotland require radical reform that cannot be achieved overnight. A land value tax will require time to implement and phase in. It will take time to pilot a universal basic income and then assess whether it is the best route to drive down poverty and drive up wellbeing, or whether it would be a minimum income guarantee. Of course, not all of what we have suggested in the report requires the powers of independence to achieve. That is why I am pleased to see much of our report feature in the SNP's ambitious manifesto for this May's election, such as doubling the Scottish child payment, community wealth building and a minimum income guarantee. Edwin Mountain. I picked up on the land value tax and I should declare that, as a farmer, I own 500 acres, which I farmed. Mixed farmed incomes last year were £8,100. That is hardly enough to survive on. How would farmers cover the land value tax that is proposed if they have only got an income of £8,000? I thank Edwin Mountain for his question. Obviously, the creation of such a land value tax would be open to consultation and how it would be implemented would be open for discussion and consultation with key stakeholders such as himself and fellow landowners to ensure that it is fair and equitable. On a minimum income guarantee, as we heard yesterday from Shona Robison, the Scottish Government is already starting work on how a minimum income guarantee could work under the current devolved settlements. Obviously, it is going to be a huge challenge as we have a hybrid social security and tax system that are partially devolved. We in Scotland still rely on decisions of the UK Government being the right ones for us. Such a guarantee is about more than social security, it is about combining wages, social security and services to ensure that we have, as citizens, what we need and do not fall below a certain level. It is achievable, but there are clear challenges from the fiscal framework and interaction with detrimental decisions coming from Westminster. The looming cut to universal credit, which will end the £20 per week uplift, for instance, will wipe away any benefit for many families of the Scottish child payment. It proves to me why we need independence so that we can direct our resources to our agreed priorities and not be harming Hamstrung and help back by the austerity economics and the austerity of ambition of successive UK Governments. I have to give way to Stephen Cack. Thanks to Neil Gray for giving way. From our previous encounters in the other Parliament, I know how passionate and admire how passionate Neil Gray is about these matters. Would he accept that his comments on the uplift on universal credit and that this Parliament does have the means to address that issue if the majority in this Parliament feels that it is an issue that should be addressed? We have the means to do that, to top up reserved benefits. That is correct, isn't it, Neil Gray? I thank Stephen Kerr for his intervention. Of course, the Scottish Government is already taking action and targeted support to address those issues, but the issue at hand and at stake here is the fact that a hybrid system of social security that we have in Scotland has been undermined by decisions that have been taken up Westminster. The £20 a week Scottish child payment that we will be looking forward to could be completely undermined with the £20 a week uplift being removed by the UK Government. I think that it would be beholden on Stephen Kerr to direct his efforts at persuading his colleagues in London to ensure that that does not happen later this year. An immigration system that works for Scotland and those who choose to make here their home not unlawfully housing fellow human beings in squalor and ripping them from their community and on raids. A social security system that provides a real safety net that provides security and does not dehumanise them in assessments and impoverish them to the point of having food banks as a de facto extension of the DWP, we can and must do better. This short debate clearly won't cover all aspects of this substantial report. There is so much in there about drug reform, land reform, housing, immigration and more besides. It not only sets out a blueprint for how we set the priorities to create a fairer Scotland but gives policy ideas to achieve a good society, a compassionate and well-being society. I hope that this evening starts a healthy, positive debate on what we can achieve and takes us forward to that goal. If we know that poverty levels are dictated by the policies of our Government and the UK Government, I hope that we can all unite behind a central goal. We should be creating a fairer Scotland that eradicates poverty. The debate that we have should be about how we get there and I look forward to hearing the ideas coming through from all sides. I thank you for calling me a bit earlier because of the circumstances. I also congratulate Neil Gray on securing this important debate and I welcome him to the Scottish Parliament. I also wish to put in record that I was a member of the Social Justice and Fairness Commission. I also like to apologise that I have to leave before the close of the debate. It certainly was a privilege to become a member of the commission and I know that some discussions challenge the orthodoxy and also the tinkering at the edges that certainly is the easy thing to do. Thinking about the type of Scotland that we should all want to see should certainly bring us all together as a Parliament but I know that it won't. The report offers a conversation starter to find consensus about the kind of Scotland that we want to build with independence and how best to get there. The commission certainly believed that independence Scotland can build on the foundations that have been laid under devolution by the Scottish Government. The report stated that we contend that eradicating poverty in Scotland is the single most important ambition that the Government of an independent Scotland could seek to achieve. As Professor Philip Alston, the UN Special Rapporteur on Extreme Poverty in Human Rights, said, "...devolved administrations have tried to mitigate the worst impacts of austerity despite experiencing significant reductions in block grant funding and constitutional limits on the ability to raise revenue." He also said that mitigation comes at a price and is not sustainable. That particular comment answers the questions from Mr Kerr to Mr Gray a few moments ago. Mitigating against UK Government welfare reform and Tory welfare policies prevents this Parliament and the Scottish Government from investing to make society better for everyone. The SNP Government has already introduced a range of progressive policies such as the baby box, a game-changing poverty reduction measures such as the Scottish child payment and the best start grants. However, there is still more to do. As Sharon Dowie commented earlier on, I want to commend her on her comments about John Scott. John certainly was someone who was well thought of and well regarded across the chamber. As Sharon Dowie said earlier in her first speech, she got involved in politics to make a difference. So did I and so did every single member of this Parliament. However, being ambitious for Scotland and helping to lift people out of poverty will not be done with the glass ceiling of devolution. It will not happen with one hand tied behind our backs. It will happen when we have full powers of independence. Brexit and the pandemic have certainly had a major impact on all our lives, and it will shape our country and our communities for decades to come. It will take decades to pay off the pandemic debt, but that is the same situation that the UK faced after World War II. However, that should not be a limit on the ambition for our people and for our country. My constituency has some of the most challenging statistics in Scotland. Those statistics are people. I want my constituency to have a better future. The debate that the chamber has heard at the surfer's turn about our justice transition ties in with the social justice report. If we want a social justice Scotland, if we want a fairer Scotland, if we want our communities to be more resilient, then read the report, consider the report, discuss the report and use it to engender more debate about Scotland and the type of Scotland that we all want to see. The status quo is finishing, and a fair independent Scotland is the prize that is coming and it will be won. Just to remind all members who are seeking to speak that they need to press their requests to speak buttons if they could all check. They have done that. I call Stephen Kerr to be followed by Rona Mackay. To Stuart McMillan, I stand as someone who is very ambitious for Scotland within the United Kingdom. I congratulate Neil Gray on securing this debate. One of the first members' business debates of this Parliament. However, the report is unoriginal. It is uncosted, which I think slips it into the territory of snake oil sales. It is the utopian fairytale, which has been drawn up by the SNP, frankly, to distract the people of Scotland from their failures in government. The report has been designed by the SNP to try and allow them to avoid accountability and to stoke up a grievance agenda. However, this Parliament already has the powers to address the most pressing issues to Estyn Scotland today. It is the SNP's dismal record and government that should be subject to debate, scrutiny and accountability. I take the following quote from the executive summary of the report. The democratic renewal that independence offers is an opportunity to reimagine our approach to local democracy. There is a strong argument for radical reform of local government, guided by the principle of empowering communities across Scotland to take the decisions that affect them. The SNP do not need independence to empower communities across Scotland. They need to give them proper funding and respect the decisions that are made by local councils. In 2013-14 and 2018-19, the SNP Government cut local government spending in Scotland by 7.5 per cent. The SNP also takes the attitude that they know better than local councillors over turning over a third of planning decisions made throughout Scotland's councils in the last Parliament. If that is not a power grab, I do not know what a power grab is. Another quote from the report reads, "...those struggling with addiction need to be heard and empowered to be at the centre of their own treatment and recovery." The Scottish Government already has the powers to allow those with addictions to be heard and empowered. Under the SNP's watch, Scotland has had a record number of drugs deaths for six consecutive years. The SNP likes to complain that it is legislation to blame for that. However, Scotland's drug deaths are three and a half times above those seen in England and Wales, who have the same legislation. The report correctly calls for co-operation. Perhaps in the spirit of co-operation, the Scottish Government can reach out to the UK and Welsh Governments to learn what they are doing to help those who suffer from addiction. Co-operation between Scotland's two Governments would also promote immigration to Scotland. With an increasingly elderly population, it is vital that Scotland is seen to be open and welcome. Sadly, the rhetoric that is associated with the nationalist movement makes Scotland feel like a hostile environment for many of our English friends. Banners such as England Get Out of Scotland—yes, of course. Thank you, Mr Kerr, for taking the intervention. I would just relate to him that his statement is incorrect in terms of the facts that net migration from the rest of the UK is positive for Scotland and has been for many years. I, of course, accept the facts, but it does not help when the nationalist movement creates a hostile environment with banners such as England Get Out of Scotland or perhaps even senior parliamentarians at Westminster, endorsing tweets that are said to English tourists to eff off and go home. I believe that the First Minister and her Government should be calling out that and condemning that kind of activity. Thank you for taking the intervention. Mr Kerr, as an English Scot, I agree with your comments about some of the terrible things that have been said, and I am quite sure that English Scots would agree, but I also have to highlight that some of the individuals that you just spoke about are not members of the SNP. I did not say that they were members of the SNP, but I would point out that Ian Blackford is definitely a member of the SNP. In fact, the SNP group leader Westminster. For social justice and fairness to emerge in Scotland, we do not need a change in the constitution. We need the Scottish Government to change how they exercise their powers, rather than seeking grievance that should seek to create an equality of opportunity for all Scots.  The SNP should be focusing on bringing us together, because Scotland is more powerful when we work together. Doing all of that and more would be working in the national interest, but I fear that the SNP will continue to work in the nationalist interest. I would next call Rona Mackay to be followed by Michael Marra. Thank you, Presiding Officer. I am very pleased to be speaking in my first members' debate of this new session, and I am exceptionally pleased to be speaking in such an important subject. I am just sorry that I had not heard Stephen Kerr's speech in advance, because I could use my entire time just rebutting all the nonsense that we have just heard, frankly.  Of course, I thank him for his exceptional work as a member of the Social Justice and Fairness Commission. In order to get somewhere on a journey, everyone needs a route map. The commission report leads the way to how the people of Scotland can live in a fairer, more equal society, one which values wellbeing, eradicates poverty and ensures no one's life behind. I certainly want this for my grandchildren, and this is the map that we need to get us there. It highlights so many key elements needed to improve life for everyone. We know that society is unequal, it seems like it always has been, but this is our chance to change it, albeit with limited powers until we are a normal independent country. Yesterday afternoon from across the chamber, we heard harrowing stories of people living in poverty in the struggles they face every day. This is Scotland 2021, and this should not be happening. We heard the Tories, and we have heard Stephen Kerr, the Tories who are responsible for most of the poverty creation in Scotland, and others say that we should use the powers that we already have. As Neil Gray said, much of it is already in our manifesto. The SNP Government has introduced the baby box, the game-changing poverty reduction measures, Scottish child payment and best start grants among many others. With independence, we could do so much more. We would not have to mitigate harmful Tory welfare policies. We could reverse Tory welfare policies such as the important two-child limit, the vile rape clause, the benefit cap, and the cruel five-week wait for universal credit. We could have a welcoming inclusive immigration policy, renewed employment rights under a fair work agenda, get rid of unpaid work trials, zero hours contracts, and fire and hire legislation. Warm affordable housing is a basic human right that is sadly non-existent for too many people. That must be addressed and could be with radical new thinking about the social rented sector. A bold drug policy based on harm reduction and recovery is happening now, and I believe a conversation about decriminalisation is long overdue. Under the UK Government, pensions are the lowest in Europe. With independence, we could lower the age of qualification and pay a fairer rate. It's the least the older citizens of Scotland should expect. The commission also proposes establishing pilots of two key models of social security, universal basic income and the minimum income guarantee. Those would be the springboard to beating the battle against poverty. I appreciate the member giving way. It's all well and good, but when you're setting out a vision or a prospectus for a future that you believe that the member believes can only achieve to an independent Scotland, you also have to tell people how this will be paid for. That might not be a very popular thing to say in this chamber tonight, but you have to be able to pay for these things. How will they be paid for, all these aggrandizments, more pensions, more benefits, more everything? I think that it's a bit of a facile comment to make. This will be costed. All the initiatives that we do will be costed. Produced as we did in 2014 in a white paper. We don't ask people to take a leap of faith in things that are uncosted. Not from a sedentary position, thank you. I can continue. There's much, much more in the social justice and fairness commission and far too much to highlight in four minutes. I thank everyone, not just the elected politicians but the many innovative members who worked on producing this report. This report is the start of a life-changing, nation-changing conversation, one that puts human rights at the heart of every decision. It provides a map I will be happy to follow and I applaud its vision for a Scotland I want to live in and one in which future generations can flourish. Thank you. I now call Michael Marra to be followed by Emma Roddick. Thank you, Deputy Presiding Officer. I welcome the opportunity to speak in the debate that Mr Gray has brought forward. I'm happy to discuss issues of social justice wherever and whenever we can. We owe it to the people of Scotland to have these discussions as frequently as we can. We also owe them honesty in the discussions that we have about them, about the difficult choices that we have to make. It's an interesting document, having read it. I hadn't read it prior to the debate being called, it's fair to say, but I'm interested to have read it since. I have the utmost respect, in particular, for Dr Ailey Whiteford. I was privileged to work with her for Oxfam for a number of years. I know her extraordinary commitment to the poorest of the world and the service that she's given to people in many countries on these issues of poverty. I was interested in a quote, and it says that policies must be grounded in consensus across society and able to weather changes in government and economic downturns. That talks to some of the hard work of politics, actually building consensus, trying to build the consensus of a whole population and seeking unanimity, at the very least, the permission of people to make progress. I have to say that I see little evidence of this in terms of the division that we see on a day-to-day basis between the young and the young, the opposition of the yes and the ultra-knows on the other side of the conversation. We've seen that in the most recent election campaign, a divisive campaign fought between two extremes thriving off each other, and that's not going to deliver the kind of essence of what's required here. A country that is divided 50-50 will not have a consensus to build any kind of vision for the future. I think that that is the challenge, frankly, that faces the SNP and nationalists if they believe that they can achieve an independent Scotland. I think that this issue of political leadership comes to the fore. For those of us who have argued our entire lives for progressive taxation, your party have not been allies, quite clearly not been allies. You fought the last two general elections specifically committed to opposing Labour's progressive taxation reforms. You talked about Labour's attainment of the NHS. Excuse me, comments through the chair. Sorry, I'll get used to it at some point. There was Labour's attainment of the NHS. That was achieved by facing downvester interests through negotiation and persuasion to make the case for it. I want to talk about the difficulty of that in tax, in particular in terms of SNP taxation policy. I think that there's a salient point in talking about how that has to be paid for, the many great aspirations in that. The history of SNP taxation policy in recent terms, the first term, is entirely regressive and targeted the impact of that cutting services for local people, often the most poorest the disabled people who require services and we continue to see the multi-billion pounds impact of that. Second term, the Laffer curve economics advocated by John Swinney in the run-up to the independence referendum. A completely ridiculous policy claiming that lower taxes will result in higher growth in this country. Andrew Wilson's growth commission austerity on steroids and that this election back again to council tax freezes. The issue in this is about how do we pay for the issues, the kind of policies that you're putting forward and building some form of consensus for that. Please. I appreciate Michael Marra giving way and I appreciate up until last couple of paragraphs Michael Marra's constructive approach to this debate. I think that we have common cause of areas in this report and I look forward to working with him and colleagues taking the forward and finding consensus. In terms of taxation will they accept that there are a number of recommendations within reports such as land value tax and other streamlinings and progressive elements towards a fairer taxation system but that also requires the full powers of taxation that we do not currently hold. Michael Marra. Certainly I don't actually agree that there are versions of land value tax that could not be implemented now without any further powers. I think that the issues that brings me to the point of the many things that are in this report that could be delivered now. Council tax reform promised for 14 years and completely undelivered and LVT is an opportunity. I would say that there is probably a majority in this Parliament for a version of that policy. Bring it forward. Land reform, local government reform, the creation of new enhanced benefits. An example of this is we were told in 2014, that it was necessary to have independence to deliver transformative childcare. Two months later, after a no-vote, that policy was put in place. That, again, is a list of things that can't be done. Frankly, the main contradiction within that is about the growth commission, the evil twin document of this, produced by Andrew Wilson and his colleagues. I will accept it, Presiding Officer. It comes to that central issue about if you are putting on one-handed a report that says that we have to do less and we will have less money, austerity on steroids and the other that we want to spend so much more, it begs the question about how any of this can be achieved and I fear that this report will go the way of the poverties that are and many other warm word promises that won't deliver what the people of Scotland desperately need. Thank you.  You went on the list. Emma Roddick, please. Before starting my speech, I would like to declare that I worked on this paper. What I really love about the paper is that it's not a complaint, it's not a whinge about lack of money or an attack on anybody else, it is a positive vision, a list of possibilities and an exploration not only of what we could do as an independent Scotland but now. The first proposal in the housing section sees a recognition of the need to not only build more homes but the right homes, energy efficient, accessible and varied in the number of rooms. That comes alongside a proposal to modernise existing stock which is welcome in terms of tackling the large emission of co2 equivalent from buildings but also in tackling fuel poverty which is a concept all too familiar can raise standards in the private sector. Now, while we must support building affordable homes particularly in rural areas such as with the SNP Government's Rural Housing Fund we cannot make policy which relies on the goodwill of landlords. We need regulation alongside house building. Expanding the social sector may be a great way to bring demand and therefore prices down but I do not buy that it will mean that the landlords who have neglected their properties of their tenants to fix issues will suddenly feel the need to raise their standards. That is why the second proposal which focuses on moving away from seeing homes as a means of asset appreciation and towards being a place to live is so welcome. Right to buy did not just eat up our housing stock it also twisted the idea of what a house should be. People purchased council houses for a few thousand, the prices rocketed and many have since been sold to absentee landlords or 20 times the price that they were sold off at. Properties that were intended for affordable rent are now owned by landlords who charge the residents hundreds more in rent per month than their next-door neighbours. That is neither just nor fair. It is why it is so welcome that this paper proposes offering first refusal on X right to buy properties to the local authority at market rate. We must stop seeing residential properties only as an investment opportunity an asset that the rich can expect guaranteed returns from and the less wealthy can expect to be ripped off in. While people wait for a home for years in temporary accommodation or have to move out of their local area just for the chance to look at an affordable property we cannot justify dozens of homes lying empty for all but two months in the summer. We cannot justify absentee landlords buying multiple homes in Skye and elsewhere in the Highlands and Islands at extortionate rates, sight unseen because they know that the price will just keep going up. We cannot justify celebrating that house prices continue to rise well out of the most optimistic aspirations of our young people. Those recommendations are a great start in righting these wrongs. If this paper can set the tone for this session of Parliament then we are in for a great one. Let's continue to dream big on how to create a Scotland with social justice and fairness at its heart. I now call Paul Sweeney who will be the last speaker in the debate. Thank you. Thank you, Deputy Presiding Officer, for your indulgence to include me in the debate. I just wanted to offer a couple of observations based on my recent personal experience of being on universal credit until last month and a particular pay tribute to Neil's work on this. I think I've already discussed this in our previous lives in the House of Commons and how important this issue is. Frankly, as far as I'm concerned I don't really care about how we do it and the money into people's pockets. However means we need to do to innovate in that regard, that's what this Parliament's about. I'm really keen to work constructively, as my colleague Mr Marra said. We are happy to work constructively in that endeavour. A good example would be the opportunity to look at the universal credit, which is already woefully insufficient and it actually makes the cost of being poor far harder for people. It destroys potential means that people's ability to even function as citizens is denied, which is a bigger cost to the community in terms of healthcare, housing arrears, all sorts of knock-on effects that are hugely disastrous for local communities. By my rough calculations, if we take the number of 110,000 people on universal credit in Scotland at the moment roughly scaling it up to the £20 a week uplift, that's about £114 million that would cost to deal with that issue in Scotland. It takes sovereignty of that issue and I think that would be a useful thing to consider in this Parliament because it pales into insignificance when you think of the costs, for example, the overspend on the CalMac ferries or even the rangers' malicious prosecution compensation of £100 million. Let's look at ways we can fix this problem now. I thank Paul Sweeney for giving way and I appreciate his experience of this matter of recent years and I welcome him to his face. Does he accept on top of the issues around the £20 a week uplift that Stephen Kerr and I were debating about? There are structural issues with universal credit that the Scottish Government can't address. The five-week wait is the number one issue that the trust will trust say is driving food bank use and that is an issue that has to be resolved at Westminster. Paul Sweeney. I thank Mr Gray for his point. I think he's absolutely correct but that's why we need to try and build constructive dialogue and I think that the antagonism has often been a comfort for many in terms of rhetoric. Let's look at what technical opportunities there are to constructively engage on this issue. I think that he makes a good point about the issue of the five-week wait. It certainly wasn't a pleasant experience for me. I didn't use the advance because I had sufficient savings to deal with that myself. However, I also realised that I wasn't able to get knowledge of what would be paid until a week before the payment so you're living in Limbo not knowing what you're even going to get. I didn't even realise until earlier this year I was also eligible for new-style job-seekers allowance. No-one's proactively advising you on what you're entitled to. I also had to go through a council tax reduction which is a separate bureaucratic procedure and other ways of income maximisation. Those are things we could probably deal with better in Scotland by having a sort of apply once and get everything you're entitled to sort of approach. Let's try and figure out how we can do that practically. I think that our civil servants are capable to deal with the DWP in the front line. They're hardworking and kind people who are trying to be constructive given the circumstances. They are Scottish civil servants. They just happen to work for a master that's not particularly constructive and helpful. I think that there are ways we can deal with that and help to advance the cause in Scotland. I'd like to see us realistically explore the way in which we can enhance universal credit in Scotland and actually deliver that output for citizens in Scotland. I think that there's a way of us doing it and I'd like to work constructively with this chamber across parties to deliver it. I just wanted to offer that insight that there's a ready, willing, capable approach in this Parliament that we can deliver something constructive for Scots. Thank you, Mr Sweeney. I now call on Minister Ben Macpherson to wind up the debate. Up to seven minutes, please, Minister. Thank you, Presiding Officer. For me, like so many others, I'd like to emphasise, like all most other speakers have emphasised, achieving greater social justice is one of the main drivers of my political activism and commitment. We can and must create a fairer society. I'd like to thank Neil Gray for bringing this debate today on the social justice and fairness commission report and the issues that it covers and also to everyone across the chamber for their contributions. I'd like to welcome Stephen Kerr to the Scottish Parliament. Although he has been provocative in much of what he has said so far, I do feel that it is in good faith. However, I would encourage him to acknowledge that the election has passed. We are in a different era now, and if he is serious about being constructive, then I would urge him to consider both the nature of his arguments and also some of the background to what he said. Obviously, I made the point about migration stats. Also on planning law, it is important to acknowledge that the reporter is, of course, independent. He has also said several times in his chamber about reaching out to the UK Government. I have had several ministerial posts and unfortunately the engagement has never been meaningful with the UK Government so if he can improve that on the matters in this report, and generally, I would encourage him to do that. Likewise, I would like to warmly welcome Michael Marra and Paul Sweeney to the chamber. I think that they talked extremely importantly about taxation and about the issues within the report. One of the things that has been missing in terms of trying to achieve social justice in recent years has been serious budget proposals from the Labour Party and I hope that their coming to this chamber can change that position. Paul Sweeney's points around universal credit are thoughtful and powerful but, of course, as Stuart McMillan rightly emphasised, we cannot be a Parliament of mitigation. We already spend £60 million a year on mitigating the bedroom tax and what I've never really understood about the Labour position is why you wouldn't want to bring the powers here so we can do things differently and, of course, that is also relevant in relation to progressive taxation where, with income tax policy, we control a number of aspects of it but not, for example, dividend income tax, so we don't have a complete control over the areas in question very quickly. Michael Marra? It's one thing to talk about making more progressive taxations. We're not a good start in place, not for the SNP Government, but for progressive taxes as they have done through the last 14 years. Minister? I wouldn't accept that in the circumstances and with the powers that we have we have sought to both give stimulus and have a fair taxation system and, of course, when it comes to income tax we have the fairest arrangement in the whole of the UK. I would also pay tribute to other speakers. The fairest income tax system in the whole of the UK where the lowest tax is to pay the least tax. I would also pay tribute to Emma Roddick for her work on the commission but also the points that she raises around housing and I'm sure Cabinet Secretary Shona Robison will be glad to have engagement with her on those points and others. I think that what's clear overall is that the political will is there in this Parliament to create social justice. We just don't have all the powers and that's what this report highlights. Nonetheless, we do all seem to want to create a Scotland where everyone can have their best start in life and lead their best lives even if we disagree on some of the best ways to get there. Recovery from the pandemic is, of course, our overriding focus right now but how we recover matters yes, we need to use our current powers well and wisely but we also need a clear route map that looks beyond current powers and should be and this is what the report by the Social Justice and Fairness Commission provides a substantive analysis of what is possible under the current powers of devolution and what will be possible with the full powers of independence. Time, especially now, won't allow me to cover everything I'd like to in the summing up speech so, like others, I'm going to focus my remarks on a few significant aspects of the report and the first I would like to emphasise on is, of course, Social Security. The Scottish Government shares the ambition as set out in the report for a social security system that provides income security for people who need it. We are committed to the principles of dignity, fairness and respect drawing on people's lived experience as we continue to build a system focused on the needs of individuals and that's why we have established the experience panels to help us design our social security system in Scotland and their input has been fundamental directly informing changes to service delivery. Throughout the pandemic, Scotland's social security system has continued to ensure that people are paid the money that they rely on while maintaining our focus on the safe and secure delivery of the devolved benefits. With powers over 15 per cent of social security spending in Scotland, we are already delivering 10 benefits, seven of which are brand new and unique in the UK. However, efforts to tackle poverty in Scotland must include efforts to change Westminster's damaging welfare policies. Covid-19 has highlighted once again the shortcomings of the UK approach. For example, the five-week wait that Neil Gray emphasised for first payments of universal credit and the two-child limit and the benefit cap. Those all needlessly and unjustly continue to push families deeper into poverty. As Minister for Social Security, I will continue to call upon the UK Government to make changes to ensure that people can rely on the safety net that they have paid into and, for them, the UK Government to match the ambitions that we have to tackle child poverty. However, those calls, while they have been made by ourselves and organisations, have currently gone unheeded. That is why what is needed is powers over social security to create a fairer system to come to Scotland. We need all of the power to deliver social policy as cohesively as possible. That applies, as I have said, equally to taxation policy and also to employment law. Until we secure independence or powers over employment law, we are therefore taking action in the meantime to use the powers that we do have to prioritise fairness, taking our steps forward, for example, towards a minimum income guarantee with the establishment of a steering group informed by lived experience and expertise. I could say so much more, Presiding Officer, on community empowerment, on land reform, on immigration, on drugs laws and so much more that is included in the report because the social justice and fairness commission report highlights a range of challenges for this Parliament as a whole and our country as a whole as we begin to recover from the pandemic and move forward together. The question for all of us is how do we deliver a fairer Scotland, a wellbeing society that values and cares for everyone who lives here? That is an overriding question for us all. How do we make life better for everyone, create greater social justice and ensure no one is left behind? What constitutional arrangement would enable us to deliver that vision as effectively and quickly as possible? The Government firmly believes that having all the powers of independence is the best way to achieve this vision and that is why considerations around the constitution are directly related to considerations around social justice. The report that we have debated today demonstrates that relationship and I look forward to many more debates in this parliamentary session on how together we can build a fairer Scotland. Thank you minister and that concludes the debate and I close this meeting.


OK, I apologize to whoever picked that song. It goes on for like 10 minutes, so I got here a little late, so sorry. OK, so today, last time, last week, we had introduced the outer space abstraction, and we kind of created a problem for the operating system to solve, which was the view of memory that we're going to give to processes is going to be a virtual view. It's not going to be real. Today, we're going to start talking about the complication this creates for performance, which is all of these addresses, these virtual memory addresses that we've been talking about, have to be translated somehow to an actual physical address when the contents are in memory. So any virtual address that points to physical memory has to be translated. We're going to start talking about some ways to do that. And this is one of those fun stories where there's a nice interplay between the operating system and the capabilities of hardware. OK, so time at 2 is due Friday. I've had a couple of emails about the late submission policy. There is no late submission policy. You will get the best score for whatever you turn in before 5 PM on Friday. That's the late submission policy. That's already up on the core syllabus, actually. There are no extensions for the assignments, except in extremely rare circumstances. Where the Scott and Guru are working on getting the assignment to submission stuff all set up, that's going to be released pretty soon. Something else that's going to come in in a new version of test 161 is checking for memory leaks. So this is not something that we will have points attached to for assignment 2, although you will get warnings about places where your kernel is leaking memory. However, for assignment 3, there will be points attached. So please start fixing your memory leaks. Given that a lot of you guys aren't familiar with C and doing manual memory allocation, I suspect that your kernels are leaking all over the place. So this will be a good tool to help you find those leaks and fix them. Oh, by the way, I'm sure there's going to be posts on discourse about this, but I just want to own up and do my little mea culpa. There is a bug in the current version of test 161 that can cause it to loop forever sometimes when trying to process certain configurations. The person you are looking at is the person who introduced that bug a long time ago. So at some point when we add this, if your test 161 hangs, you can thank me. Please upgrade to the new version. We just fixed that this morning. So never write an infinite loop. Just don't ever do it. Even if it's for i equals 0 to a million, it should terminate at some point. Otherwise, you will be embarrassed later. OK. Any questions about virtual addresses? So last time, a couple of times ago, we talked about the address face abstraction. We have each process a big uniform view of memory. We pointed out last time that clearly that abstraction requires breaking the connection between physical memory and the view of memory the processes have, and we introduce the idea of a virtual address. Any questions on this before we do just a few minutes of review? Everybody understands this already. Awesome. OK. So what I'm doing here is I've created a new level of interaction. So what does that buy me? I'm forcing processes to translate a reference to memory to gain access to it. What are some of the things that that allows the kernel to do? What are some of the new powers that I get by forcing processes to translate a virtual address into a physical memory address? There are some of the new tricks I can play. Yeah. OK. So I can enforce access. I can enforce permissions and access requirements. So I can prevent processes from stomping on each other's memory. That's good. What else can I do? Yeah. Yeah, I can enable sharing in a nice way. And that sharing can actually, so two processes can actually share the same physical memory at different virtual memory addresses, which is kind of neat. So I can choose if I want to share a process a and process b want to share memory. Process a and process b can both set up different virtual addresses in their own address space to point to the same physical memory. That's kind of cool. What else can I do? I haven't talked about probably the most important ability that this gives the kernel. Yeah. Yeah, so that's a cool thing. I can make memory. I can use discontinuous physical memory to create contiguous virtual memory. That's awesome. What else can I do? One more thing that's pretty critical to memory management. Every time you use an address, I'm going to translate it. Yeah. Yeah, so that's great. So this gives me the ability to do uniformity. Every process thinks that if a process forks 10 times, all 10 copies of that process think that a particular local variable or global variable is located at a particular address, despite the fact that those addresses are clearly different. They have to be. Each process has a private address space. But there's one other thing that other thing is I can move things around. So I can take memory that was memory and I can put it somewhere else temporarily. And when the process needs it again, it has to translate this reference. And that gives me the ability, that gives the kernel the ability to make it look like memory again. And so we'll talk about this in maybe this week or next week. Well, week after when we talk about swapping. OK, remote shared, moved, altered. OK. So clearly the address space abstraction requires that I break the connection between the addresses that a process uses and the physical memory addresses. And if you don't understand this, I would encourage you to go back to last lecture and look at that example at the end again, because that is critical to understand. Addresses the processes we're using are not real. They are translated. And you can convince yourself of that pretty easily by writing some pretty simple C code. And we refer to these as virtual addresses.  And last I've asked the kernel to map it into a file or something. These are addresses will behave like memory. They obey the memory interface. But they may or may not be actual memory. So a physical address points to actual stick of memory. A virtual address points to something that acts like memory. That's to obey the memory interface, in most cases, although we talked about some variations of that. So we can see what you use. Absolutely. Every address you've ever used in C is a virtual address. Do the experiment. I mean write a little C program and just play around with this. Write a C program, have it 4, 10 copies of itself. And you can see they are using identical memory addresses and storing different values. So clearly something weird is going on. You've known something was wrong with the world all along. Just telling you what it is. OK. So yeah, we talked about virtual addresses. And because I'm forcing the process to translate a reference, I have the ability to do a lot more and layer on a lot more power into this process. So we talked about four system calls that create virtual addresses. Now remember, when I'm creating a virtual address, all I'm doing is I'm giving the process permission to use this address to address something that is kind of going to behave like memory. In some cases, these things point to memory. In one case, they actually don't. So exec, what is, what virtual addresses does exec create and why? Yeah. Yeah, so it moves, yeah, exactly. You guys probably are figuring this out by now. That is one thing it does. How many people have that working? OK, good luck to the rest of you. Have a plan, all right? You won't get anywhere without a plan. Yeah, so what else? But that's only, that's just the part of exec that you guys know and that it's going to give you nightmares for the next week. The exec does a lot of other things. Most of it's done for you in OS 161. What else, what other virtual addresses does exec create? What other parts of the address space? I just called I to use somebody else. Decides where to start the heap, that's true. How does it make that decision? Yeah, say it. Maybe the file labels? Yeah, those are usually the, so the file table lives in kernel memory. We're talking about user virtual addresses. Remember, what other big part of a process's address space is exec directly responsible for? Yeah? Code? Code, yeah, that's the big thing. Code, static variables, everything that's initialized when the program starts up. So when the program starts up, I've got to move all that stuff from the L file into the address space. And that's mainly what exec does. If you guys look at loadL, it's doing a lot, it's doing quite a bit of work for you. You're just putting the cherry on top. OK, fork. Where does, what virtual addresses does fork create and why? Yeah, and what is that, what virtual addresses does that address space have when it starts up? Yes, modulo a few things. The child starts up with the exactly same addresses allocated as the parent. That includes all the code, all the static variables, any global variables that the parent may have changed, all of the heap that the parent had when it was running, everything. The parent and child are supposed to be mostly indistinguishable once they start to execute. What about sbreak? What's sbreak for? What does it do? I just called on you. He did give away the answer, though, if you were listening. I'm working on my ability to tolerate uncomfortably long silences in class. So I can get somebody to speak up. Sbreak, what does sbreak do? What uses sbreak? I'll give you this one. Extends the process heap. So when you've been using malloc, malloc calls sbreak internally, sometimes, not all the time, but sometimes. Finally, mmap, who remembers what mmap does? Mmap is the one that creates virtual addresses that do not point to physical memory. There's a hint. What do they point to instead? Don't point to their virtual addresses. They don't point to virtual memory. Mmap says, map a portion of what into my address space? Yeah, a file, not even the disk, a file. That map allows me to create a portion of my address space that looks like memory. I can read and write to it like memory, but all the changes to it are written down to some part of a file. OK. All right, we won't go through this. This is boring. All right, any questions on virtual addresses before we go on? So it's important to get this concept sort of firm in your mind. So now we're going to talk about actually how we get this to work. So somebody pointed out last time that we've created a potentially serious problem for ourselves. What is it? The virtual address abstraction requires that the kernel translate or the kernel participate in the process of translating every memory access. Yeah, I mean, memory just got super slow, super slow. Imagine if every time you access memory, you had to trap into the kernel, the kernel had to somehow do something to the address.  So this is clearly not OK. Our goal here is that the kernel, in cooperation with hardware, the only way to make this fast is to get the kernel out of the way. This is one of the few cases where software is just way too slow to do the job. If the kernel has to be involved with every memory access, the machine would never, like computers just would never have happened. You guys wouldn't have one, because people would have said, this is way too slow. So the only way to make this system faster is to get the kernel out of the way, get the kernel off the critical path. And that's because the kernel is too slow. Now this is another case of a nice divide between software and hardware. So going back to the CPU, going back to how we did CPU scheduling, what is the kernel's primary responsibility when multiplexing resources? What is it in charge of? Yeah. Yeah, so what we want is we want the kernel to control all the policy aspects of address translation. How addresses get translated, permissions attached to them, blah, blah, blah, stuff like that. But we want the hardware to provide mechanism so that this is fast. So the kernel needs to maintain complete control over virtual address translation, while the hardware makes sure that most translations don't require the kernel's help. Does this make sense? So the goal here, the kernel maintains control over how address are translated, but is not involved with translating specific memory addresses. So here's one way that we could try this, which is what I refer to as explicit translation. So here's what happens. Process says, I have this virtual address I want to translate. Can you tell me what physical address it translates to? Can I do this? Can the kernel answer this type of query? Yes? How many people think yes? How many people think no? Why would, what's the problem with doing this? What have I just given away? Well, there's two problems with this. First of all, remember, can a process use a physical memory address? That's over. User processes do not get to use direct physical memory addresses. In fact, the kernel doesn't even get to use them anymore. All addresses are translated in some way, according to rules of the kernel sets. But all addresses are going to trigger some sort of hardware translation. So there's no such thing. I can't use a physical address. I also can't tell the process how I'm translating things, because if I give away my translation now, if I want to change things in the future, if I want to make sure the process stops using that memory, I can't do it anymore. So all addresses must be translated. I have to translate all the addresses, or in blurry basis. OK. So this is how things actually work. And this is why you've never noticed this before. When a process does a write or read to a memory address, this triggers a translation process in which something called the MMU, anyone want to guess what that stands for? Memory Management Unit, there we go, is in charge of translating addresses. That's the job of the Management Management Unit is to organize this address translation process. And the first time a process tries to translate a specific address, the MMU doesn't know how to do it. And so what the MMU is going to do is it's going to ask the kernel for help. How does it do this? What's the mechanism here? Yeah, this triggers an exception. Remember how we talked about most exceptions are completely benign and occur completely naturally? This is the case of an exception. When the process ran this instruction, it did not know that this exception would be triggered. But this instruction cannot complete until the MMU knows how to translate the address. So it has to figure this out. It traps into the kernel. The kernel has to do one of two things. Either the kernel has to translate the address or what else could happen? The kernel has to tell the MMU how to translate this address, what physical address it translates to, or I can do what? I hear muttering. Does someone want to mutter louder? Make a route? Well, no, so that is telling the MMU what to do. So either the translation can complete or what else could happen? Segmentation fault. It's possible that this address is not translatable by this process. The process doesn't have permissions to do what it's trying to do to this memory address or the process doesn't have this address as part of its address space, in which case I can't complete the instruction. Yeah, Josh. Yeah, so how do processes run out of memory? So processes usually run out of memory on most systems because they hit some sort of predefined limit that the OS sets that they can't exceed. That's the, so on a well-administered system, you have policies in place. So for example, a user program at a particular priority can't allocate more than a certain amount of memory. Now there's cases where the OS can run out of memory and there's also cases where there's not a lot to do. We'll come back to this. The way that Linux handles this is just by killing things at random. Basically, right? It's not, I'm serious, you guys are laughing, but it's not completely random. I shouldn't make fun of like this. They have this thing called the out-of-memory killer, but you talk about black magic. I mean, that thing is impossible to understand, but essentially what it does is, because at some point you're kind of like, the only thing I can do is kill a process. What's not important? And it tries to figure that out using a bunch of heuristics. So we'll come back and talk about that in a moment. Does that answer your question? Yeah. Cool. All right, so this is how I want things to happen. The MMU sees an address, it doesn't know 100% how to translate. It generates an exception. The kernel runs. The kernel tells it, hey, by the way, this virtual address maps to this physical address. The MMU says, thanks, and the store completes. Notice that the process has no idea what just happened. All the process done is do a loader, a store, or whatever the equivalent memory operation is, and all this happened automatically. So from the process's perspective, it just executed one instruction, and now it's gonna execute the next instruction. All this happened behind the scenes. Okay, so here's our example. Let's go through it again. The MMU triggers the kernel, doesn't know what to do. The kernel tells it how to do something, and that triggers it, so now we have a diagram for the visual learners among us. Now, what happens when this process starts running and another process starts to run? Does the MMU still know how to translate 0x10,000? It does. People are nodding. Who wants to make an argument why it doesn't? Yeah? We'll point to it differently. Remember, a virtual address is meaningless without a process. If I ask you to translate a virtual address, you cannot do it unless I tell you what process is running, because every process has virtual addresses that are in the same range that point to completely different places and completely different parts of memory. So every time a process switches, I have to reset the MMU and teach it how to translate addresses again. This is another part of the overhead of doing a context switch, is that the MMU's translation cache, which we're gonna talk about in a sec, is flushed and has to, I have to reload things again. Okay. Now, here's the nice thing. So let's say it's the same process, it's running along, it hits this address again, now what happens? So the first time I translate the address, the kernel gets involved, tells the MMU what to do. The second time I translate the address, what happens? Yeah? It's in the cache. And so the kernel doesn't get involved. This is the trick that we use to get the kernel out of the way. Now, we're gonna talk in a lecture or two about why this works. Specifically, there are patterns to process memory management. If process is accessed random memory all the time, if the memory accesses by processes were completely randomly distributed throughout all the parts of their address space that were valid, these caches would not work very well. But they're not, as you would expect, right? If I'm executing code, all the memory, let's say I'm running a bunch of instructions and I'm just loading and storing a bunch of instructions from the same part of memory, all those loads are just sequential from my code section. So it turns out there's quite a bit of locality that allows this to work. In general, if I tell the process, if I tell the MMU what to do, I don't have to tell it again for a while. You can translate a bunch of other addresses. Okay. Now, this can also happen. So this is the case where the process didn't know what to do. This just makes sense. Address translation, okay, yeah. Good question. So when would I need to remove an address from the cache? I've got this MMU. You've made the correct assumption that the MMU cannot cache an infinite number of translations. When do I need to remove translations? Yeah. So if it's out of the process exits, if I do a context which I have to clear the cache, what other condition might I hit where I need to clear the cache? Yeah? It gets full. It gets full. And at that point I need to figure out what's the right translation to remove and get rid of it. So, and those are the two reasons that I would remove a translation. The other case is it's possible that the kernel has made a change to how that memory is mapped and needs to remove it from the cache. So if I've made a decision that has caused the process to not have access to that memory anymore, then I need to make sure to get it out of the cache. We'll talk about this when we talk about swapping. Yeah. So now, so this example, the problem with this, well okay, what's a problem with this approach as I've described it so far? How effective is this cache going to be? This cache, according to my silly example, is translating one virtual address to one physical address. So how effective is this cache going to be? Let's say that I'm executing an instruction sequentially. Every one of them is gonna trigger a new translation lookup. And the kernel's gonna have to run. So this is bad. So in general, what we try to do is, what we need to do is find ways to tell the MMU how to translate more than one address at a time. If all I do is tell the MMU one at a time, here's how this byte translates to, this virtual byte translates to some physical byte, this is gonna be a mess, it's gonna be really slow. And so what we're gonna do now, we'll talk about several ways to optimize the process by being able to instruct the MMU how to translate a bunch of addresses at the same time. So I don't have to, the kernel doesn't have to keep running and slowing everything down, okay? So here's the simplest virtual address mapping works as follows. I assign each process a base physical address and a bound. So the base address is the place in physical memory where this process starts, don't worry, I have a diagram in a minute. And the bound actually determines the size of the virtual address space. And then, here's how, and there's two things that the algorithm needs to be able to do. The first thing it needs to be able to do is figure out, is the address valid? The second thing is, it has to be able to translate that address, translate a virtual address to a physical address. So this algorithm, or you can think of this interface as having two parts, one is check, the other is translate. Also keep in mind, this is implemented in hardware. And hardware is pretty limited in certain cases in terms of what it can do. And so making this fast means making this as simple as possible. The nice thing about base and bounds is that it's really simple. To check, I just make sure that the virtual address is within the bounds that I've assigned to the process. And to translate it, I take the virtual address and I assign it and I add it to the base address and I'm done. So this is very easy. Here's my example. Let's go through 0x10000 again. The MM, so now this determines for each approach, there's different pieces of information that the MMU needs to retrieve from the kernel to translate an address. So in this case, I ran, the process tried to translate an address, the MMU didn't know how. And the kernel said here are the base and bounds for this process. Who can finish the job? So how do I translate 0x10000 into a virtual address? What would the virtual address, sorry, physical address, what would the physical address be that 0x10000 in this case would translate into? Yeah. Well, what is it? Exactly. So I take the base, no, no, no, no, wrong, sorry. How do I do this again? Base plus what? Base, virtual address plus base. So what's my physical address? Yeah. 50600. Let me pause and just reveal to you something about me that's going to make you very happy, because I'm a relatively benevolent person. When we do these examples on exams, the arithmetic is always base 10. Thank you. Actually, I should say you're welcome, because no one wants to do hex arithmetic. At some point I'll fix the slides, but when we do this on exams, you guys can do base 10 arithmetic and use your fingers like everybody else. But you should probably at some point learn to add hex. It's not, well, I shouldn't say it's not that hard. I don't know how to do it. Anyway, so these examples are all pretty simple. So I take the virtual address, here's my base. Now here's the thing. You can notice this is the process's entire address space. So its virtual addresses started zero, its physical addresses started 0x40600, but my whole address space is right here. And so this hits at one of the limitations of this approach. The nice thing about this is once I've told the MMU these two pieces of information, I'm done. There's nothing else I need to tell it. And it can translate other addresses completely happily. Here's another one. There's the case where you'd have to do some hex math. But I can translate all of the addresses in the address space until I'm done. Now what does this trigger? How do I translate this address? What does this address translate to? Boom, yeah, this is out of bounds, right? My check is to determine, is the virtual address less than the bounds? In this case, the size of my address space is only hex 30,000. So this address is off the end. This would be out here somewhere and I can't translate it. So this would cause the process to crash. Or this would call this the kernel to fail the translation and abort the process. So the nice thing about this, yeah, sorry. So for base and bounds, it's a requirement. The only way this works is if the entire address space is located in memory and located in the contiguous physical memory. So despite the fact that this is simple, it stinks for our address space abstraction. The address space abstraction, the idea, remember, is I was gonna give address spaces this huge view of memory that was big and contiguous and it lets them spread out and put the code way over there and the stack way over there. And I can't do this with base and bounds. So with base and bounds, I would have to have these tiny little address spaces and now I create all these problems associated with doing it. So this is the major con of this approach. There also turns out to be a lot of external fragmentation when I try to lay these out because of how they fit in physical memory. So yeah, remember again, if this is my base and bounds, I've got way too much stuff. And if I encourage processes to spread out, even if I could get this to work, I still have all this wasted space. So all those gaps between the parts of my address space have to be located in physical memory. I have to allocate physical memory to them. So yeah, this is a problem. So let's try something else. Let's get closer to a modern approach. You may have noticed if you look at this diagram that the traditional layout of process address spaces isn't a, you know, it's a bad fit for a single base and bounds, but it's not a terrible fit for more than one base and bounds. So I can extend this idea using something called segmentation. And segmentation is not the modern way that we actually do address translation, but it's intuitive enough that a lot of systems still include the idea of a segment, despite the fact that the granularity of address translation is actually small. We'll come back to what this means. The nice thing about segments is I can, rather than having this one huge segment, so base and bounds is like one segment for the entire process, I can use individual segments to cover each contiguous part of my address space. And this means that I can eliminate all of that wasted space. And I can assign different permissions to them, they can be different sizes. So going back to this example again, I have one segment here, I have a second here and I can have a segment for each stack. So let's see how this works. Every segment, so there's one additional piece of information I need to get segmentation to work. With base and bounds it was implied that the process virtual address space started at zero. Here, each segment's gonna start at a different virtual address, so that's an additional piece of information that the kernel has to communicate to the MMU to get this to work. So there are, each segment has a start virtual address, a base physical address, so that's where the start maps to in physical memory and then a size or a bound. To determine, so there's an additional step here that the MMU has to perform, which is when I try to translate a virtual address, it has to ensure that that virtual address is inside a valid segment. If it doesn't know, if the virtual address is not inside a valid segment, it'll produce an exception and the kernel has to either tell it that there's a valid segment that exists that contains this virtual address or kill the process if the address is invalid. Once I determine the segment that this virtual address falls into, there's one additional little piece of math I have to do which is I have to subtract off the start of the segment before I add the offset to the base physical address. I can't believe I said that right. I think I did actually. Let's use the diagram. Okay, so here we go. OX 10,000, our favorite address. Kernel gets involved. It says, yes, MMU, there is a valid segment for that process that contains this address. It starts at virtual address OX 10,000 and the location of it in memory is OX 43,000 and the size is 1,000 hex. So what physical address does OX 10,000 translate to in this example? Yeah? OX 43,000? OX 43,000? Remember, the start translates directly to the location of physical memory. Any other addresses that are inside the segment I have to compute an offset and do the math but the start is very easy. So the start always maps directly to the base. What about OX 10,000 and 10? Where would that map? 43,000 and 10. Compute the offset with respect to the start of the segment, add it to the physical. So intuitively there's a chunk of physical memory out there that corresponds to this segment. And what I'm doing is I'm mapping the physical addresses corresponding to this segment into that chunk of physical memory. So, now in this case, what happened? OX 400, is it inside of a segment that the MMU knows about? Yes or no? No, it's not contained. So this segment starts at OX 10,000 and runs up 1,000 hex. So it ends at OX 11,000. This is not inside that. And so the MMU has to ask the kernel, does there contain a valid segment? Now normally the answer here would be no because this is close enough to being a null pointer that I would probably make sure that there's no valid translations in this part of the address space. But here because I didn't want to use big numbers, let's pretend that it's true. There is a segment down here, it starts at OX 100, it has a 500 bounds and maps to OX 16,000 in physical memory. What is the translation of this address? 15,000, 16,300, exactly. So I took 400, I subtracted off the start which was 100, I had an offset of 300, I add that to the base. How many questions about this? This is pretty much math. But simple math, like third grade math, right? There's no linear algebra required to do this. Just addition and subtraction and hex, sorry. What about this address? What do you think's gonna happen? I should do this next year and have it be valid because it could be valid, it could be a valid address. That beef is a silly address. It turns out to be always invalid on the MIPS that you're using, but it could be valid. So if I can't find a segment, I kill off the process, right? And now you understand this error message. That's exactly where this error message comes from. So you've seen this error message segmentation fault core dumped. It means that you try to access invalid memory but the reason it's a segmentation fault goes back to the idea of using segments to manage virtual memory addresses. Which again, is still something that operating systems do as a logical concept to understand how to apply permissions to things and stuff like that, despite the fact that the mapping mechanism has done a little bit different. So now you know what this means and you can impress all of your friends who are still writing C code for some reason. Tell them to do something different. Okay, so is this an ideal solution? So there's some nice things about it. One nice thing about it is it's pretty simple. It's still pretty simple. It's a little more complicated than base and bounds. Obviously, there's a little more information. There's a little more work I have to do. It's really nice that it allows me to organize and protect contiguous regions of memory because in a lot of cases, that's how address spaces are laid out. And this is the reason that this has survived to the modern day, this concept. And it's a better fit for address spaces because there's not all this internal waste. What are some problems with this though that might lead me to wanna do something a little bit different? Yeah, so I still, if you think about having to be the kernel and allocate physical memory, which is what you're gonna have to do, this is still a little bit of a pain because every segment is a different size and so it creates this sort of external fragmentation problem where I might need to allocate a segment that doesn't fit in any of the areas that I have free and physical memory. So that's too bad. What else though? Yeah. Yeah, where? Yeah, so not only does this create an external fragmentation problem, it also creates an internal fragmentation problem. Imagine you're talking about Microsoft Word, which is always my favorite thing to beat up on. How much source code do you think Microsoft Word has? Like a small amount? Medium amount? Like an enormous amount? Yeah, we're getting warmer, right? All of those features that you don't know how to use, all those ways to do the same thing that are super confusing and poorly documented. I'm gonna get in trouble one day. I'm never gonna get money for Microsoft for anything, clearly. Anyway, like I bet even who thinks that there are Microsoft Word power user, right? Who could teach me how to use Microsoft Word? Really? It's that bewildering? There's one person up here. Okay, so that's awesome. I bet that you haven't used half of Microsoft's Word's features. Is that fair? You think there are menus that I could open that you've never seen before? Yeah, okay, so all of that code has to be in memory despite the fact that you're not using most of it. So the fact that the entire segment either has to be in memory or not in memory is a problem because there's a lot of potential for internal fragmentation or internal waste inside those allocations. And then I have this external fragmentation problem as well. So this is not quite good enough. You guys seen the squirrel fishing videos? Has anyone seen those? Google Squirrel Fishing. Google Squirrel Fishing Harvard specifically, right? There's a fantastic website set up to document a really important research project that took place right outside where I used to work then involved trying to determine how aggressive squirrels would be if you dangled a peanut on a string. And it turns out some of them are real go-getters. Okay, anyway, there's one that actually, there's a liftoff picture, but they're actually holding onto this peanut for dear life and it's being tugged into the air. It's awesome. I mean, that is the squirrel that you want to hire. All right, so let's regroup here and think about our design requirements for this problem. So we're getting closer, right? Segmentation is useful. Base and bounds is way too simple. So what would we like ideally? Ideally it would be awesome if we could map any virtual byte to any physical byte. That's kind of where we started. The problem with doing that is that the amount of translations that the MMU would have to know about gets really, really huge. So both segmentation, if you think about base and bounds and segmentation. So if I need to map any virtual byte to any physical byte, the MMU's cache is going to be able to map a very small amount of physical memory. With base and bounds, I could actually map the entire address space with one piece of information in the MMU. With segmentation, I can map the entire address space with only a few pieces of information in the MMU and I did a better job because I didn't have as much waste. So we're going to keep going in that direction. We're not going to be able to map any virtual byte to any physical byte. And the operating system won't be able to do this anyway. The question is, is there a middle ground and is there a way to use a smart piece of hardware? Okay, so let me introduce something called the translation look-aside buffer, or the only thing you will ever call it is the TLP. How many people think that they know how this works? Really? Okay, I was expecting a couple of you. And this is one of our classic operating system design principles. On some level, your computer, I think I've said this before, is really just a series of caches. You have small, fast things that cache slower big things.  I mean, that is the modern cache hierarchy. It's incredible how large it is and how many different sizes there are. So this is what we're gonna do. Something's too slow, we're gonna throw a cache at it. The thing that's too slow here is address translation. And the cache that we're gonna throw at is something called the translation look-aside buffer. So these take advantage of a very clever hardware capability that allows me to do a parallel lookup of a bunch of things at once. This is something called content addressable memory. So most memory, let me see if I can explain this. Most memory is addressed by the location. For content addressable memory, you actually address it by the contents. So if I'm looking for something, this is very helpful because instead of trying to find it by looking at all the places it could be, I tell the hardware what I'm looking for and the hardware can find it extremely efficient. All right, so here's to some degree how these things work. So if I was looking, if I was normally, let's say I'm trying to translate a particular virtual address and I'm using the TLB to do this. One way would be to search individually every mapping. How does this scale? So if my TLB has n entries, how long will it take to do a linear search through the n entries to find the math that I'm looking for? Order n, that's not too hard. I haven't taken 331, but I still know how to do that type of big old stuff. So the nice thing about a CAM is I can do all these searches in parallel in order one. Now you might be asking why is this awesome property not exposed to me in more ways? The problem is that the amount of circuits that you need to implement this grows roughly proportional to the number of slots squared. It is not good. So CAMs tend to be small. You might have a CAM that allows you to search for 256 entries or 512, but at some point the amount of circuit area and transistors that you have to devote to this thing is not scaling well. So you can't make a four gigabyte CAM. That would be awesome if you could. Computer size would be different if that was the case. Very different. On the other hand, I can use a small CAM to help the MMU cache certain address translations and search for them efficiently. And it turns out that on modern systems we have all these different permutations of certain CAMs that have certain properties and they have these nicknames and stuff like that. Who cares? That's stuff for the hardware we need to worry about. Just think of the fact that you can do this efficient search through a small number of things in O1 time. Well, I think I just explained all the caches. I can't make this CAM unbelievably large. Now if I could make this CAM unbelievably large, I could actually do what we wanted to do which was to translate single virtual bytes into physical bytes. Because eventually I could teach the MMU how to translate every virtual byte in the process's address space to individual physical bytes. And that would be pretty cool. Because the CAM is a limited site, I can't do this. So let's think about trying to develop a middle ground. So segments are too large. Individual bytes are too small. This would be the TLB wouldn't be able to cache very many entries. And so is there a middle ground here? The correct answer is, of course, there's a middle ground because there's a middle between these two things. And the middle ground is something called pages. So I have ended early for the first time this semester. That's interesting. On Wednesday, we're going to talk about page translation. Good luck with the sign of two. I'll see you guys then.


Egin! Silydd is research programme manager at the protocol labs. I was amus to see in her biography likes to believe she's a rising star golfer as do we all. Silydd is going to talk to us about research road mapping, permissionless discourse for improved foresight coordination. Delighted to be here to talk to you about research road mapping. It's fun to talk about the importance of network and collective knowledge after this talk. So research road mapping is a special project within network codes as protocol apps. Network codes is a team focused on identifying, fostering and rewarding the creation of public goods. Is this moving? Okay. And how can we accelerate and optimize the creation of scientific public goods? And we claim research road maps are valuable coordination models to optimize the creation of those codes. They are dynamic and shareable instruments through which an inclusive set of stakeholders coordinate and align on the most impactful research paths, match problems and capabilities and embed incentives to maximize positive impact. And this is precisely the hypothesis we want to test. And to do so, we want to create a portfolio of actionable road maps, the ones we use to make informed decisions, and a reusable infrastructure for research road mapping that enables decentralized peer-to-peer incentives alignment between stakeholders. Hopefully, in doing so, we'll gather enough evidence to support our claims and establish research road maps as revolutionary scientific coordination systems. But let's look at what research road mapping actually is. So research road mapping is both a knowledge sharing activity and a tool for scientific coordination problems. The road mapping process requires research stakeholders to engage in a conversation where they share latent knowledge and identify leverage points in a research network, openly and transparently sharing assumptions and does it knowledge to quantify costs, impact and uncertainty of alternative paths and aligning on the creation of incentives, requests for experiments or investment thesis. A strategic planning and vision alignment exercise that results in a map. And that map is a goal-centered graph representation of the alternative path enriched with quantitative data to support decisions. A shared network of research goals, milestones and dependencies to bootstrap research collaborations and foster alignment between researchers and research funders, hopefully filling the gaps in research, fostering scientific discoverability and pushing the scientific frontier forward. And although it's easy to recognize the value of road mapping for coordination, there's much to be done to drive that adoption among researchers, R&D labs or industry labs and revive the openness mindset of science. We need to make it easier to create, share, navigate and update roadmaps, guarantee value attribution to those that contribute the map or use the map for decisions and incentivize high impact research path both prospectively and retrospectively. So let's start with the knowledge sharing part. Road mapping research requires knowledge exchange models. A data model, a common language to translate and combine knowledge from different fields, experts and views into an iterative and parsable graph that makes research paths are certainable. Multidisciplinary and interoperable data models that track knowledge across the sciences, enabling evidence-based decisions and scoping of research initiatives. And those models should be expandable, querable and personalizable to facilitate semantic merging of knowledge graphs, enabling different levels of precision and granularity without compromising the mergeability of graphs or the use of AI assisted tools either to synthesize knowledge or to make predictions. Besides, establishing priorities of ideas and aligning research needs require a substrate where this conversation can happen. Coordination protocols and instruments that allow crowdsourcing of ideas, gap analysis and prediction of research costs, risks and impact as well as the prediction of risks and impact so we can scope down anti-risk research initiatives. However, the adoption of research road map is hindered by a subpar user experience. In terms of tooling, we are missing good graph navigation tools, the capability of querying graphs or link nodes or whatever is a graph in the case, although we represent a road map to start with. We are missing collaborative features for decision making. In all these challenges, we are limiting the production of collective maps that would boost science discoverability. Speaking about collective road maps, we need research infrastructure to make it easy to create, collaborate and share knowledge. In fact, what we are missing is a playbook on how to road map a specific area of knowledge. How do I get started? What are the tools that I can use? What kind of models should I use? After I'm done with it, after I made my decision or after I wrote my grant proposal, what do I do with the map? Do I just write another PDF and publish it as a vision paper so that any other person needs to go to the process of breaking it down in parts again, creating a graph, putting it together, making decisions, write another PDF? How can we break this cycle? How can we make these instruments citable? We also need to have incentives in a way that researchers, funders, politicians or any other research stakeholders feels comfortable sharing their ideas in the open without the fear of being scoped. We need to track those contributions in a way that we can establish value attribution, either if they create impact or if others build on top of the knowledge they created. For instance, as I mentioned before, network codes is a team that works a lot on these revolutionary coordination models. We have innovative mechanisms to fund public codes, including research public codes such as iPerser's that are linked at the end of the presentation. These incentives are not necessarily just financial incentives. They also need to account for the metrics that you value in research like reputation. Is it collaborating or making a research map public something that you value on the metrics that you use to evaluate our own researchers? Or is the research risking their reputation by contributing to these instruments? If until this far this seems quite intuitive or useful as I sure hope so, I claim it's because I'm using a set of knowledge exchanges models that were developing with our extended network of writers and partners. On my right, we have discourse graphs. This is a schema that maps scientific arguments into their constituent parts. So we have the research question that we are trying to solve, all the claims that we made that would provide a solution to that question.  We generate results, hopefully gathering evidence that will either support or oppose the claims we did. On the left, and pardon for looking because I'm terrible at mixing up right and left, we have what I call a research road mapping schema. When you are mapping a new area of knowledge, usually there's a goal or a question that you want to answer. And in order to answer that question, there are a certain set of desired data properties or user needs that we need to account for so we can actually accomplish that goal. And usually those properties are enabled by core technologies or approaches, and they can be limited somehow. So there are a set of new capabilities in green that we need to add to those core technologies again that will enable desired data and will answer our research question. And finally, here we have in blue the open problems that are all the questions that are problems that haven't been addressed yet. And there are somehow blocking the progress here. So without going into too much detail, and because road maps are all about collaboration, our impact is perceived through our network of impact that includes cross institutional and multidisciplinary scholars, school builders, or practitioners either developing those protocols, developing the support infrastructure, or stress testing this in practice to plan for research initiatives or the risk science. So if you have suggestions, a topic to run an experiment with, or you went to somehow support the development of the space, please reach out to us. Or if you want to know more about the initiative and innovative work we do at network codes, there are some links here. And this is a QR code that lets you download the presentation so you can have all the links and emails. Thank you for your attention. Great. Thank you Sylvia, very much. Sorry we're a bit tight for time. We've got a minute and a half for questions if anyone would like to come forward. We've got one colleague there. Yes, far away. Thank you. Jeff Alexander with RTI, the Research Triangle Institute. So I'm trying to operationalize what you're talking about because I'm sympathetic to your ontology. But road mapping, I'm coming at this from the industrial technology road mapping kind of background, usually has some consensus around the end goal. For example, it's coming back to us. It was staying on Moore's law. I think one issue we run into with science is that especially in a multidisciplinary environment, one, we use different terminology for the same questions. And two, we have a lot of disagreement about it's a somewhat adversarial kind of process of, well, which way to go is really based a lot on some theory that may not have a common body of like shared understanding or shared agreement. How does road mapping overcome that kind of adversarial disagreement and actually get consensus on a path forward? That's actually a great question because one of the things that we've been claiming as well is that we need some kind of government system or voting system to attach to these kind of mechanisms. So how do we actually shape collective roadmaps? You have your own road map. It's your vision of the Swiss air mine. How can I merge them? And of course, we need a common language, but we need to disambigwate if we are using the same term for different things. So this is one of the open problems that we've been facing. I'll do a merge them semantically. And fortunately, there's a lot of AISS tools that already happen helping the system. But until we come up with this portfolio of roadmaps that we can actually study and operate on to make decisions, we won't know for sure. It's just something that we guess. We assume that it's hard to combine them because of the implicit knowledge. But a road map, I will also claim that a road map is not a good road map if you can't navigate it without a lot of implicit knowledge. So I don't know. We can discuss it further if you want afterwards. Thank you. Great. Thank you, Sylvia, again. And thanks also for the links for people to follow up. Thanks again.